Movement Player in 3D/2D

Hey, Does Anyone know how to rotate the 3d player but in interact 2d ??

We can ask engineering to help.

What are you trying to do? Manipulate 3d rotation based on 2d location?

yeah that’s right, i want to rotare my player and enemy but i don’t know how to do that

Which version of Cocos you are using?

the same topic

cocos creator 2.4

I am installing 2.4 to test it. However, in 3.X.X its very easy and even reminds a bit of Unity.
I will try to mimic something for you on 2.4 and I will send you a project if succeeded…

thank youu

I created project for you.
The 3D object will rotated based on a given 2d vector mouse position.
Just move your mouse cursor around…

The trick is to cover the 3d obj with an empty node. Then move the the empty node around.

In any case, looks like the entire 3d in CC 2.X.X is very optional. (819.0 KB)



            if(this.distance >4){


                this.isMoving = false;



    }else if(this.distance <5){"Skelet.c|walking")

        let flip2 = cc.tween().to(1, { angle: cc.v3(0,90, 0)})

        let flip = cc.tween().to(1, { angle: cc.v3(0,this.flipEnemy(), 0)})

        let move = cc.tween().to(1, { position: cc.v3(-1.27,this.node.getPosition().y, 0)})

        let move2 = cc.tween().to(1, { position: cc.v3(1.34,this.node.getPosition().y, 0)})

        this.moveTween = cc.tween(this.node)






        this.isMoving = true;




heyy thanks youu
but i want my enemy move to the location that i already set and flip their face

here my code

Ok so now that I see more clearly where it is going, you can try the follow:

  1. You can use ray-cast to pinpoint location on 3D space.
  2. You can set movement by using transforms.
  3. You can apply rotation to objects using the cc.Quat and cc.quat().

How to use?

  • Use ray-cast until it touches the place you want the object to rotate to.
  • Calculate the direction between the ray-cast point and the object.
  • Use atan2 to get the radian angle of rotation.
  • Use cc.Quat.fromAxisAngle to get the new rotation (Just like in unity).
  • Apply the output quat to the object to rotate it.

hey but i read the cocos 3D docs and seem like i don’t find the way move character by using transforms.

I can ask engineering to chime in again :slight_smile:

can you give me the link

In version 2.4.x, you can directly
Use node.setPosition to set the position of the node
Use node.setRotation to set the angle of the node

Hey, why i can’t using the apply Force in cocos creator 2.4

Is this the physical system you are referring to as applyforce?

applyforce is available, for 2.4.x version applyforce you can have a look at this API RigidBody · Cocos Creator