First, a little background on my setup. I am making a side scrolling shooter. I have setup an item pickup which enables two ‘options’ that orbit the players ship. I have achieved this by having a game object attached to the player with 3D models and shot spawns as children, then a rotate script is attached to the game object so it appears as if the options are orbiting the player. When the player hits an in game pickup the game object is set active and the options appear. When the player takes a hit they are set inactive.
The problem i’m having is when the player takes a hit an animation plays, this animation is messing up the rotation of the options parent game object. It also messed up all my shot spawns attached to the player but I fixed those by doing this for each spawn:
ShotSpawn1.transform.rotation = Quaternion.Euler(0f, 90f, 90f);
ShotSpawn2.transform.rotation = Quaternion.Euler(180f, 90f, -90f);
ShotSpawn3.transform.rotation = Quaternion.Euler(0f, -90f, 0f);
etc...
but this method will not work for the options game object, no matter what I set the numbers to they are always something different in game. I have tried disabling the script which rotates the object, then re-enabling it after a short delay, but this doesnt help.
This is my rotate script:
{
public Vector3 eulerAngleVelocity;
public Rigidbody rb;
void Start()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
Quaternion deltaRotation = Quaternion.Euler(eulerAngleVelocity * Time.deltaTime);
rb.MoveRotation(rb.rotation * deltaRotation);
}
}