|
|
|
 |
Attention |
Topic was automatically imported from the old Question2Answer platform. |
 |
Asked By |
Help me please |
I have a mob and a player in a 3d scene of a game and till now I am able to move the mob twards the player but unable to rotate it towards the player. please someone help me
Use the look_at method of your mob node.
AFE-GmdG | 2021-07-05 09:00
|
|
|
 |
Reply From: |
EineKartoffel105 |
You can use the look_at() function:
look_at ( Vector3 target, Vector3 up )
For example, you could add the following code to your mob script:
func _physics_process(delta):
look_at(player_reference.global_transform.origin, Vector3.UP)
Of course, this is not a perfect solution since it would also make the mob rotate up and down towards the player, so you might want to set a custom y value in the target Vector.
by using $mesh.look_at(player.translation, Vector3.UP)
it rotates in the opposite direction of player. Any way to fix it?
Help me please | 2021-07-06 05:13