Hello everyone, I am trying to get an enemy to look at an object as it passes the object.
When the scene starts I call LookAt(direction) in the enemy script. When the enemy gets near the object I call LookAt(Object) and it rotates the enemy to look at the object. When the enemy is no longer close to the Object I resume calling LookAt(Direction). However when I do this it points the enemy backwards, but continues moving in the correct direction.
I’m really confused at this behavior. If anybody could help explain what might be going on it would be greatly appreciated
Thanks
Edit: It looks like its changing my direction when using LookAt() I don’t understand that
Hard to say for sure without seeing some code, but a difference I notice in your description:
LookAt(Object) sounds like you’re calling LookAt on a position (in global coordinates?), while LookAt(Direction) sounds like you’re calling it on… well, a direction, which you presumably want to behave as an offset from where the player is (for example, if the player is at position (x, y, z), and the direction is (0, 0, 1), you would want to look at the global position (x, y, z+1)) - is that correct?
If so, that probably explains why it’s behaving differently.
I’ve Accounted for that already, but thanks. Speaking of when you import a model to Godot is it best to make sure that its facing in the -Z in the software you’re importing from?
Ok so I figured out my issue. The direction the enemy was headed was being rotated by the global rotation of the enemy before Velocity was calculated. However when I was calling LookAt(direction) I was not rotating that direction. So the enemy was moving in the correct direction, but not looking in the correct direction.