I am a 3d designer venturing for the first time into C# and Unity over the past few days. I have been working on a little space shooter project (following some 3D Buzz tuts) but have been adding elements of my own functionality with some relative success. However, a problem I have been having is establishing how to make the spaceship slightly tilt as it moves in the direction it is travelling (ie just left and right).
The way the game is created I know the ship needs to tilt on the Y Axis (left for positive, right for negative) and will need to hold some relationship to the ships translation. The script for the translation is as follows:
first tilt the ship to how you would want it to look while moving. then record the rotation (on paper)
the when you move left or right transform.rotate(x,x,x) depend on which axis you are rotating multiply it by Time.DeltaTime
actually i came up with a sort of easier wayā¦ use animations. it works perfectly for a helicopter. but yours is of course probably a lot better because its in codeā¦ but oh well.
Hi! I know this is really old but Iām trying to figure out why itās not working. I implemented this code exactly, but this is what it looks like: https://imgur.com/a/k1VyyET
I tested this in a new Unity project to make sure it was a problem with the code and not with other scripts, and the same behavior occurs.
I really needed this simple code, but Iām having a problemā¦ I edited it a little bit to work with my code. It works but only if my player doesnāt face the camera, otherwise it would tilt the wrong way. Hereās my code: