Hi all, can somebody help me please to create script to control my ''dot''? Basically I need to make controller - first tap on the mobile screen - dot will start moving to left side, second tap - will move it to right and again 3rd tap left,4th tap right etc. so basically dot will fly in space and I need to control it (right and left) only with one touch or eventually mouse click. Thank you for your time and please help me
Hi, Can you show your code so far? Where are you stuck? Or you should probably follow couple tutorials first, then making that script would be easy: http://unity3d.com/learn/tutorials/modules
Code (CSharp): //we create variable to see where the dot is going currently public bool goingRight = null; void Update() { //we'll start off by saying that the dot will move forward by default even if it goes to right or left transform.Translate(Vector3.forward * Time.deltaTime * 4f); //now we'll check for inputs from user (left mouse click) if(Input.GetMouseButtonDown(0)) { //we'll set by default that first direction will be that it'll go towards right and each click will 'tick' the boolean on and off, meaning it'll turn right then left on each click goingRight = !goingRight; } //now let's set the rules for it going to each direction if(goingRight) { transform.Translate(Vector3.right * Time.deltaTime * 3f); } else { transform.Translate(Vector3.left * Time.deltaTime * 3f); } }