In a 2D topdown game, I’d like to instantiate a prefab positioned directly behind another. Much like a ship laying mines; they should appear in the opposite direction from the way the ship is facing.
How do I get the vector that describes the direction the ship is facing and how can i translate backward along that vector to find where the position the mine should be?
My ship moves between waypoint vectors using the following script:
float step = speed * Time.deltaTime;
transform.position = Vector3.MoveTowards(transform.localPosition, waypoint, step);
Quaternion qTo = Quaternion.LookRotation(transform.position - waypoint, Vector3.forward);
qTo.x = 0;
qTo.y = 0;
transform.rotation = Quaternion.Slerp(transform.rotation, qTo, rotSpeed * Time.deltaTime);
Any help would be great.