Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7619521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:42:29+00:00 2026-05-31T03:42:29+00:00

I am newbie on Unity 3d.I have started practising with a snake game. I

  • 0

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.

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 > 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;
}
}

The error is:

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?

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T03:42:30+00:00Added an answer on May 31, 2026 at 3:42 am

    The problem is this line

    public body first_body;
    

    You declare a variable whose type is body, but body is not a built-in variable type such as float or bool.

    And in your script, i don’t know what you actually want to do with the variable first_body, is it the snake body? can you explain more about “first_body”?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Complete rails newbie trying to get started. I have two classes, Ingredient, and Unit.
Newbie question. I have a NSMutableArray that holds multiple objects (objects that stores Bezier
Newbie question... The objective: I intend to have an HTML text input field as
Newbie question. I have Django models that look like this: class Video(models.Model): uploaded_by =
As a developer, I'm a newbie to Unit testing and have a requirement to
I have a newbie question - I searched the web for a long time
A newbie question. (ADDED NEW INFO) I have a set of time stamped data
Another newbie question. The goal: each ingredient can have zero or more unit conversions
I have a Django project, and I'm somewhat of a newbie in it. I
I am a newbie in tdd. I have watched Brandon Satrom's videos. I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.