Search Unity

Second jump script

Discussion in 'Scripting' started by DavidSandrik, Jun 20, 2019.

  1. DavidSandrik

    DavidSandrik

    Joined:
    Aug 15, 2018
    Posts:
    18
    Hi,

    I am working on first person level. I want to make an effect when player picks up an object in the jump position, by picking up this object, player gets additional jump. This second jump will occur automatically but the player will set the direction of the jump by looking at the upcoming direction. I am thinking about to add little freeze before the second jump so the player gets some time to pick the direction of the jump.

    I would appreciate to get some direction, on which functions to look at in this situation. I was thinking to use Slerp function but since I am using Stardart FPS player, maybe I can use somehow some "jump" fictions from the FPS script. Any ideas how to do this in most simple way?

    I am attaching as well a small pic which describes in short, what I want to do.
     

    Attached Files:

  2. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    3,201
    When the player collides with the bonus item, trigger a coroutine on the controller which freezes their other movements before trigger your second jump after a set amount of time or new input (or whatever your design may be).

    https://learn.unity.com/tutorial/coroutines