I want a simple AI that turns away from an object, but i am struggling to get the ai to get it to work.
How to get the inverse of look_at()?
- Edited
Since you know the position of the subject and object nodes, you have the vector from the subject to the object. Reverse the vector to get a point in the opposite direction, and have the subject look at that point.
Welcome to the forums @ThatNyanDev!
Another thing you can do to get the opposite rotation is call look_at
normally and then rotate the node by 180
degrees on the X or Z axes, which should make it look in the opposite direction.
Also keep in mind that if your AI uses Godot Z+ as "facing forward' that the convention is Z- for look_at().
So look_at() will turn your AI to face away from the target.