How to make the characters always facing the front, no matter how the camera rotates?

DEMO: Physics V3 Simple scene with Aggregate | Babylon.js Playground (

No matter how the camera rotates, when holds W, the character walks forward, the orientation is always forward

This is the effect I want.
Uploading: 1693468035062.mp4…


Instead of using the camera target, parent the camera to your character root and position it accordingly: Physics V3 Simple scene with Aggregate | Babylon.js Playground (

I detached the camera controls, since what we want of the mouse movement is to rotate the character, not the camera, you just have to add that part :slight_smile:

1 Like

In this case, the camera’s rotation zoom and so on is gone.
I want to keep these functions

I added this code, and the characters can always face the front.

But why is-1.6, I don’t understand, this value is experimented by me, is there any more correct way of writing?

And after adding this code, when holding w, i can’t move forward

You can implement the zoom manually

I still feel that the perspective of rotating characters is better,
It’s just that in this case, after pressing W, the angle is changed, but the character does not move.

Physics V5 Simple scene with Aggregate | Babylon.js Playground (

player.body.setLinearVelocity(frontVector, player.transformNode.getAbsolutePosition());

hk.setTargetTransform(player.body, player.transformNode.getAbsolutePosition(), quaternion);

These two sentences are executed at the same time,
the characters will not move,
I don’t know how to solve

hk.setTargetTransform(player.body, player.transformNode.getAbsolutePosition(), quaternion);

This line is not going to do anything, because you need to pass the position where you want the player to be, not the position they already have. See the function documentation:

And since setTargetTransform already sets the velocity of the body, you don’t need to call setLinearVelocity.

Here’s an example where I’m setting targetTransform to a desired position: Physics V5 Simple scene with Aggregate | Babylon.js Playground (

alright, thank you very much