Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
Hi beautiful people, i have this piede of code i'm working on:
when i do a print(posicionVector3); it returns the actual position of the object, but when i try to print the values of x,y and z it shows 0 for the 3 of them. ¿somebody knows what i'm doing wrong? Thanks. |
||||
|
You cant assign variables to object properties like that: var [x, y, z] = posicionVector3;This would only work in case positionVector3 is an array, but it is an object with properties x, y, z. You can access them like posicionVector3.x, posicionVector3.y, and posicionVector3.z; var x = posicionVector3.x;If you want to do it one line you can also do: var [x, y, z] = [posicionVector3.x, posicionVector3.y, posicionVector3.z];Though, I'm not sure the last one works with CopperCube version of JS engine. |
||||
|
var pos = ccbGetSceneNodeProperty(cube, "Position"); ccbSetSceneNodeProperty(newCube, "Position", pos.x, pos.y, pos.z); |
||||
|
Thanks people. |
||||
|
Though, I'm not sure the last one works with CopperCube version of JS engine. Yes the line var [x, y, z] = [posicionVector3.x, posicionVector3.y, posicionVector3.z]; Works. |
|