Hello....
I have an aimer object which rotates around the z axis to "point" at where the mouse is on the xy plane (2D).
The aimer object is a child of the player object.
there is a firepoint object which is a child of the aimer object & therefore inherits the rotation of the aimer object. the firepoint object does not have it's own rotation.
When firing there is a projectile which is a child of the firepoint object, to which we apply AddForce in the direction firepoint.transform.right....... which is the direction the aimer is pointed at (it starts pointing right at 0 rotation).
However, in certain circumstances I need to move the player object (top parent in the hierarchy) instead of the projectile, in the opposite direction to where the aimer is pointing.
the script is on the player object.
using rigidbody2D.AddForce (-firepoint.transform.right * fireforce) only makes it go straight up. using "transform.up" (for the player object the script is on) does the same thing.
how do I get a direction vector to put into the AddForce to get the player to go in the opposite direction to where the aimer is pointing, when all I have to go on is a z rotation?
↧