# 2,5D game jump script with multiple linecasts to check if grounded

Hello there!

First I have to apologize for a very noob question I should’ve found answer to myself. I’ve been playing around with unity for merely few weeks and trying to learn scripting from the tutorials and examples. I completely do understand that instead of asking somebody to help out, it would be much more beneficial for myself to find the answer through learning the basics better.

However, after experimenting multiple options and being stuck for a week now, I’ve decided to ask here in case some kind sould wouldn’t mind helping me out.
What I’m trying to create is an 2,5d platformer game. I find it absolutely necessary to have multiple linecasts to make jumping reliable even on a uneven ground. However I’m finding horrible problems trying to figure out how to make it work. I’ve went through the example script from the Unity Projects 2D Platformer by Unity Technologies and the script provided by Invertex in this thread: http://forum.unity3d.com/threads/how-to-deal-with-characters-at-the-corners-of-platforms.223204/. However my multiple attempts trying to combine them in many different ways have failed miserably.

This is what I’ve come up with this far:

``````private Transform groundCheck1Center;
private Transform groundCheck1Left;
private Transform groundCheck1Right;
private bool groundedC=false;
private bool groundedL=false;
private bool groundedR=false;
private bool grounded = false;
void Awake()
{
groundCheck1Center = transform.Find("groundCheck1Center");
groundCheck1Left = transform.Find("groundCheck1Left");
groundCheck1Right = transform.Find("groundCheck1Right");
}
void Update()
{
groundedC = Physics.Linecast(transform.position, groundCheck1Center.position);
groundedL = Physics.Linecast(transform.position, groundCheck1Left.position);
groundedR = Physics.Linecast(transform.position, groundCheck1Right.position);
if((groundedC = true) ||(groundedL = true) || (groundedR = true))
{
grounded = true;
Debug.Log ("grounded");
}
else
{
grounded = false;
Debug.Log ("not grounded");
}
if(Input.GetKeyDown(KeyCode.UpArrow) && grounded)
jump = true;
}

``````

The problem seems to be that the script returns grounded as true from the very start of the game and never changes it’s value. I did manage to get the single linecast version to work using the 2D Platformer script, so the problem shouldn’t lie in finding the groundCheck - objects.

Look up the difference between the assignment operator (`=`) and the equals operator (`==`).