Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Cube Translate x and -x Zoi style Game

Discussion in 'Scripting' started by abdoubelbala, Jul 27, 2014.

  1. abdoubelbala

    abdoubelbala

    Joined:
    Aug 4, 2012
    Posts:
    51
    Hi every Body i want to make tthe same style of game zoi and i'm asking in making a cube translate and back i do that with script and i have the cube translate in one direction and do that again with animation but i have a probleme that the cube does not translate normaly it look like an obstacle make him to zigzag. any response please
    thank you
     
  2. smitchell

    smitchell

    Joined:
    Mar 12, 2012
    Posts:
    702
    You'll need to show us your code so we can help you
     
    abdoubelbala likes this.
  3. domkia

    domkia

    Joined:
    Aug 19, 2012
    Posts:
    99
  4. abdoubelbala

    abdoubelbala

    Joined:
    Aug 4, 2012
    Posts:
    51
    there is the code
    function Update(){
    if(transform.position.x <4){
    transform.Translate(Vector3.left *0.1f);}elseif(transform.position.x >-4)
    {
    transform.Translate(Vector3.right *0.1f);
    }
    }

    but i have the cube translate in one direction
     
    Last edited: Jul 28, 2014
  5. abdoubelbala

    abdoubelbala

    Joined:
    Aug 4, 2012
    Posts:
    51
    domkia likes this.