Search Unity

Discussion Jump - For a Fast Paced Chaotic Game

Discussion in 'Game Design' started by dadadies, Mar 2, 2023.

  1. dadadies

    dadadies

    Joined:
    Jul 13, 2022
    Posts:
    28
    I am working on a AI jump / navigation system. The jump works but the problem is that when the character sort of get stuck, they accumulate jump force. So when they succeed in jumping, their jump is multiplied apparently. Iv thought of some tricks / solutions but not sure what to do yet. So I would like some suggestions for the jump from others. Everything is built from the ground up, minus the game engine. So I might be doing things that are completely bad practice or just whatdafuk.

    Here is how my jump is working. The default jump is about 3 feet. But with the getting stuck issue, i could end up +100 feet in the air. This video is an older video and its not as bad. With some optimization to other parts of my overall code, the jump multiplication now is more aggressive. Like they will rarely jump 3 feet anymore but like 15 feet most of the time. It has to do with how im doing my jump check.

    https://twitter.com/dadadies/status/1630490088604942338?s=20

    Update: I used a cheap temporary trick to avoid the 'getting stuck' issue. I simply turn off the collusion on the character for a moment when jumping. I also implemented the clamp suggestion. Thanks CodeSmile.
     
    Last edited: Feb 17, 2024
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,892
    It fits the style, doesn‘t it? I mean absurd and superhuman agility is tradition for kung-fu movies. :)

    Anyhow, you should post the jump code if you want help. Could be anything really. I‘m guessing you react on a collision event, apply an up force, but collision events can occur in quick succession thus rapidly adding more velocity by repeatedly applying the jump force. A very simple fix would be to clamp the y of the velocity to a reasonable max value within FixedUpdate and a timeout for re-applying jump force again (eg one second).
     
    dadadies likes this.
  3. dadadies

    dadadies

    Joined:
    Jul 13, 2022
    Posts:
    28
    Thanks for the suggestion. Yes iv thought of something like that as one solution. Because the jump as it is, in fact works amazing for both the player and AI and its super fluid and smooth and fast in response. I will be keeping your suggestion as a simple solution to work on.

    Iv also considered the timeout idea. But it will likely stop the AI from being able to jump successfully if fails on the first try. Not only that, the AI would have to maybe reposition itself and try a new position to jump. But that would be embarrassing for the AI. So im trying to just make the jump work better by somehow detecting and or avoiding getting stuck in the first place + clamping the jump.

    The code is a simple if(listJump.Count > 1) then rb.AddForce(new Vector3(0, jump, 0), ForceMode.Impulse). listJump is connected to a box trigger.
     
    Last edited: Feb 17, 2024