Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

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:
    17
    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
     
    Last edited: Mar 2, 2023
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    2,480
    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:
    17
    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, and does not interfere with anything you are doing. So I like the jump system and would prefer not changing it much but instead fixing what I can. 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 the timeout is met. So then the AI would have to maybe reposition itself and so on. 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. I havent worked on the jump code much but the logic is more or so complete for now. Ill be adding getkey to build the jump force in place of the unintended get stuck feature that is building the jump force now. But thats a simple addition.
     
    Last edited: Mar 2, 2023