Node rotation in 3.5 in cocos

Can you help me with node rotation like moves up and down in cocos 3.5 .

can you send me any references or links or doc .

Thanks in Advance .

Ok, I’ll try and help explain a bit. It can be pretty complicated and if you know any of this already I am sorry.

So when it comes to rotations we use Quaternions and for positioning Vector3 within a 3d space. Vec3 and Quat are the classes used in Cocos. Vec3 has 3 axis and Quat has 4 axis.

Vec3 has: X Y Z
Quat has: X Y Z W

So depending on axis is what you want to increase to make it rotate. As an example:

update(){
this.node.setRotation(new Quat(this.node.getRotation().x+1,this.node.getRotation().y,this.node.getRotation().z,this.node.getRotation().w));
}

Should increase the x axis rotation by 1 every update. Making it spin in the x axis.

I haven’t tested the above but that should work.

Hopefully this helps.

it is rotating but the third image is coming totally after 2nd click

Not too sure what you mean by “third image is coming totally after 2nd click”. The rotation is on update not click. If you’re saying it’s rotating too quickly then reduce +1 to something like +0.1 etc

this.node.setRotation(new Quat(this.node.getRotation().x+0.1,this.node.getRotation().y,this.node.getRotation().z,this.node.getRotation().w));

if I click the button the images should move up and down like spin mechanism

if you want to get the idea you can go through spin mechanism in cocos in you tube .

Thanks

I’ve gave you a few ways to do it in this thread:

I haven’t unfortunately got the time to build the mechanism for you though. You must figure out how to do each individual part in cocos.

Thanks

Thanks