Note that there are some explanatory texts on larger screens.

plurals
  1. POMoving object head on click in unity
    primarykey
    data
    text
    <p>I am newbie on Unity 3d.I have started practising with a snake game. I have to move snake head forward first.If i press any key then the snake should start moving ahead.For its head i have taken simply a cube. Here is the code. Please tell me where i am doing mistake.</p> <pre><code>public class SnakeMove: MonoBehaviour { public bool Move_Up; public bool Move_Below ; public bool Move_Right; public bool Move_Left; public body first_body; public float time_movement = .5F; public float following_movement; // Use this for initialization void Start () { Move_Up = false; Move_Below = false; Move_Right = false; Move_Left= false; following_movement = Time.time + time_movement; } // Update is called once per frame void Update () { if (Input.GetKeyDown(KeyCode.UpArrow)) { Move_Up = true; Move_Below = false; Move_Right = false; Move_Left = false; } if (Input.GetKeyDown(KeyCode.DownArrow)) { Move_Up = false; Move_Below = true; Move_Right = false; Move_Left = false; } if (Input.GetKeyDown(KeyCode.RightArrow)) { Move_Up = false; Move_Below = false; Move_Right = true; Move_Left = false; } if (Input.GetKeyDown(KeyCode.LeftArrow)) { Move_Up = false; Move_Below = false; Move_Right = false; Move_Left = true; } if (Time.time &gt; following_movement) { MoveHead(); } } void MoveHead() { if (Move_Up) { first_body.move(this.transform); this.transform.position += transform.forward *transform.localScale.z; } if (Move_Below) { first_body.move(this.transform); this.transform.position += -transform.forward * transform.localScale.z; } if (Move_Right) { first_body.move(this.transform); this.transform.position += transform.right * transform.localScale.z; } if (Move_Left) { first_body.move(this.transform); this.transform.position += -transform.right * transform.localScale.z; } following_movement = Time.time + time_movement; } } </code></pre> <p>The error is:</p> <blockquote> <p>Assets/Scripts/SnakeMotion.cs(92,8): error CS0246: The type or namespace name `body' could not be found. Are you missing a using directive or an assembly reference?</p> </blockquote> <p>Should have I to make a body script also? N what should be included in that script? Or Can i run without making separate Body script also? Sorry for my english.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload