Problem with making the character jump

I’m trying to make the character jump with the space bar, but I don’t know how to make it work with scripting. Could someone help?

please post your code thus far. If you don’t have any code yet then it’s a bit early to ask in the scripting forum, google search for some unity scripting tutorials.

Just import the “Character Controller” asset and drag the First Person Controller into your scene. By default, it can jump by pressing the spacebar: no need to implement that by yourself.

Here’s the code, I don’t know how to check if the character is on solid ground. Also this is supposed to be a third person game.

// Check to see if the player pressed space
if(Input.GetKey(KeyCode.Space))
   velocityY = 5.0f;
		
// Launches the character in the air
if(velocityY>0)
{
   posY += transform.position.y + (velocityY * Time.deltaTime);
   velocityY -= 0.1f;
}

// Move the character
transform.position = new Vector3(posX, posY, posZ);

Going through this tutorial should help:

Not the best person to give advice but that line I bet is part of the problem

No, that line is fine.

The problem is there’s no simple “this one bit is wrong” with the above code, it’s more to do with how he’s trying to program it, which is why I pointed him to the tutorial.

You probably know a lot more than I do so thanks for the info

I just thought using GetButton would be a better idea
Like I said Im not really the one to give anyone much advice haha