2d Game Jump Issue

Hi Unity,

I wrote a script that allows my player to jump bu adding force in the y direction, what im trying to achieve is disabling the character from jumping a second time before it actually hits something from below (ground, box, enemy, etc).

I tried using the get ground hit but thats only for wheel colliders.
Thought of using filtered collisions by tags, and that would restrict me to ground, unless i tag other objects too ( i dont mind if i have to, but) that would include if i hit a box from the bottom for example which om trying to avoid.

Any suggestions, and solutions obviously welcome

Thnx in advance

Cheers :slight_smile:

2 Answers

2

This is the best solution for jump of character controller. Please go through it.

jumping code of character controller

Change the axis according to the need.

HTH…

what is that html you are posting? says Server not found

Here is the [web link to CharacterController.Move][1], @sonaviswam posted the offline documentation link in his own PC. [1]: http://docs.unity3d.com/Documentation/ScriptReference/CharacterController.Move.html

I am sorry. i edited the link.

There was a 2D platformer project from Unity demo, with a very complete script on CharacterController. Unfortunately, the package is no longer there anymore.

if you have CharacterController on your player you can do this

function Update() {
    var controller : CharacterController = GetComponent(CharacterController);
    if (controller.isGrounded) 
{
  // do something
}