Search Unity

Unity controlling an object!!

Discussion in 'Scripting' started by Munkholm, Feb 25, 2010.

  1. Munkholm

    Munkholm

    Joined:
    Feb 25, 2010
    Posts:
    1
    i have to make some code that deactivetes the buttons left and right
    My code looks like this

    function Update ()
    {//Movement of object
    var move = Input.GetAxis ("Horizontal") * speed;
    /*This should be deactivated after you press down.*/

    move *= Time.deltaTime;
    transform.Translate (0, 0, move);
     
  2. andrea85cs

    andrea85cs

    Joined:
    Feb 10, 2009
    Posts:
    11
    This script move the gameobject only if you don't press left or right mouse button;

    function Update () {
    if (!Input.GetMouseButton(0) !Input.GetMouseButton(1)) {
    //Movement of object
    var move = Input.GetAxis ("Horizontal") * speed;
    move *= Time.deltaTime;
    transform.Translate (0, 0, move);
    }