Question by
Crazetens · Sep 18, 2017 at 12:47 AM ·
movement scripttransform.translatemovepositionvector3.distancevector3.position
move a player at specific distance to road lanes
I am currently creating a five lane highway style that has the character gameobject move to the next right lane on on right button click and the previous left lane on left button click
the following is my code;
public class PlayerMotor : MonoBehaviour {
private Vector3 moveVector;
private float speed = 5.0f;
private float horizontalspeed = 0.8f;
void Update () {
//X Left an d Right
moveVector.x = Input.GetAxis ("Horizontal") * horizontalspeed;
if (Input.GetMouseButton (0)) {
if (Input.mousePosition.x > Screen.width / 2)
moveVector.x = +speed;
else
moveVector.x = -speed;
}
}
}
Please help!!
Im new to unity..
Thanks..
untitled-2.png
(94.9 kB)
Comment