0

I have a 3d model. It consists some streets.Actions are go straight, go back, left turn, right turn.

I attach a .cs file to camera. I use to go back&go staright below code :

v.z = this.gameObject.transform.position.z;
v.y = this.gameObject.transform.position.y;
v.x = this.gameObject.transform.position.x;

if( Input.GetKey( KeyCode.UpArrow ) )
    v.z += 0.5f;
else if( Input.GetKey( KeyCode.DownArrow ) )
    v.z -= 0.5f;

It works for me. I attach a diffrent .cs file to the gameobject of 3d model. The file content is :

void Update() {
    if( Input.GetKey( KeyCode.RightArrow ) )
            transform.Rotate(new Vector3(0, 0, -0.1f*Input.GetAxis("Horizontal")));
    else if( Input.GetKey( KeyCode.LeftArrow ) )
            transform.Rotate(new Vector3(0, 0, +0.1f*Input.GetAxis("Horizontal")));
}

But when I try to left&right turn, I am staying behind the buildings.

How can I turn right or left regularly in 3d model using model?

EDIT

My coordinate system and scene view is :

enter image description here

zakjma
  • 2,030
  • 12
  • 40
  • 81

0 Answers0