Search Unity

Space Shooter - tilting ship forward and backwards

Discussion in 'Editor & General Support' started by The_Widow_Maker, Nov 24, 2014.

  1. The_Widow_Maker

    The_Widow_Maker

    Joined:
    Nov 21, 2014
    Posts:
    10
    Hey all

    Just started using Unity and have completed the Space Shooter tutorials from the asset store and would like some help please. I want to make my space craft tilt forward and backwards when the movement buttons are pressed, I managed to get the desired look by changing the code in the player controller like this.

    From
    rigidbody.rotation = Quaternion.Euler (0.0f, 0.0f, rigidbody.velocity.x * -tilt);

    Too
    rigidbody.rotation = Quaternion.Euler (rigidbody.velocity.z * vTilt, 0.0f, rigidbody.velocity.x * -tilt);

    the problem I get with this is that when either moving forward of backwards any shots fired will go through the asteroids instead of making contact with them. I did quite a lot of playing around to try and fix this issue but had no success. I think it is because the spawnShot that fires the bolts is moving with the parent and causing the shots to fire at different angles that cannot be seen from a top down perspective.

    Any help would be appreciated, thanks.
     
    Last edited: Nov 24, 2014