Hi guys, I’m trying to figure out a simple algorithm but I can’t find any solution, so any help will be appreciated
So here is my problem. I have a GameObject that follows my player but I want the GameObject to always be on the right side of my player no matter the rotation of it. So I want my GameObject to follow the orientation of my GameObject not word relative.
So for example here is what my current script is achieving
And here is a picture of what is happening with my script
And here’s what I need
When I rotate the player I need the GameObject to go to the new _destination and face the same place as the player. Ps : the 10f means the distance between the player and the GameObject.
I have a current script which is part of my Mobs AI.
transform.rotation = playerTarget.transform.rotation;
_destination = new Vector3(transform.position.x, transform.position.y, playerTarget.transform.position.z); // this give me the rotation along the world orientation
transform.position = Vector3.MoveTowards(transform.position, _destination,0.3f);
Thanks you very much