Hello,
I really don’t know what should I do… I have no more ideas I’ve already seen some q&a about rotating but “I still haven’t found what I’m looking for”
I’m creating 2D game and now, I’m making object rotations. I think my English is bad so I add a picture for you with that, what I’m thinking about.
Object has to rotate only on Z axis while its moving up or down or sides.
I wrote that, but an object is just making a really silly things when I move - I know that .
public float speed;
void Update () {
float movelr = Input.GetAxis("Horizontal") * speed * Time.deltaTime;
transform.Translate (movelr, 0, 0);
float moveud = Input.GetAxis("Vertical") * speed * Time.deltaTime;
transform.Translate (0, moveud, 0);
if(Input.GetKey(KeyCode.C))
{
transform.Rotate(0,0, Time.deltaTime * 180);
}
//and I have gravity, when object is falling I have to rotate him on Z axis, I hope you understand me :/
if (transform.position.y > -4.5f)
{
Physics.gravity = new Vector3 (0, -4.5f, 0);
}
}
I start with unity and C#, please guys, help me
Thanks