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.
  2. Dismiss Notice

Jumping in slowmotion

Discussion in 'Physics' started by denwik, Mar 21, 2021.

  1. denwik

    denwik

    Joined:
    Sep 22, 2017
    Posts:
    27
    Hi!
    A question about 2D physics.
    I'm trying to make a good 2D-sidesscrolling controller. I want to utilize slow-motion in my project.

    In the image bellow you can se my problem. The blue border is supposed to be the apex of a jump. But when the game runs in slow-motion it over-shoots it a small lenght.

    What am I missing? :)


     
  2. CreakyVibez

    CreakyVibez

    Joined:
    Feb 22, 2021
    Posts:
    6
    try modifying the velocity. add a * Time.deltaTime to rb2D.velocity.x and if thats not good enough, make a speed variable and add * speed as well
     
    denwik likes this.
  3. denwik

    denwik

    Joined:
    Sep 22, 2017
    Posts:
    27
    Thank you very much for the answer. But the "rb2D.velocity.x" is not the problem here. It's just there to zero out the velocity in Y so the jump is not affected by the current velocity in y. So the jump is always the same force/height. But thanks anyways! :)
     
  4. CreakyVibez

    CreakyVibez

    Joined:
    Feb 22, 2021
    Posts:
    6
    well id like to try and help you more. are you trying to make a slowmotion happen automatically or when the player presses a button or key?
     
    denwik likes this.
  5. AlTheSlacker

    AlTheSlacker

    Joined:
    Jun 12, 2017
    Posts:
    326
    If you can get this to look OK without changing the fixedDeltaTime, I suspect the physics will be more consistent. There are a couple of useful threads to read, one analysis of scaled time by @Edy and I think a couple by me looking at the implications of semi-implicit euler integration and small displacement errors. I'll try and edit this later with links... Sorry on phone atm.

    Edit: Links
    https://forum.unity.com/threads/adjusting-time-fixeddeltatime-by-time-timescale.869491/

    https://forum.unity.com/threads/not...owing-seb-lagues-kinematic-tutorials.1038586/
     
    Last edited: Mar 22, 2021
    Edy and denwik like this.
  6. denwik

    denwik

    Joined:
    Sep 22, 2017
    Posts:
    27
    It will go in to slowmotion when the player is in the air and is about to fire an arrow from a bow. A little like in Breath Of The Wild
     
  7. denwik

    denwik

    Joined:
    Sep 22, 2017
    Posts:
    27
    Thanks! It actually works if I don't alter the fixedDeltaTime, but it stutters, but if I'm using "interpolate" on the player it looks and works great. But I'm afraid of that this will slowdown the game when it scales to a lot of characters.
     
    CreakyVibez likes this.
  8. AlTheSlacker

    AlTheSlacker

    Joined:
    Jun 12, 2017
    Posts:
    326
    CreakyVibez and denwik like this.
  9. denwik

    denwik

    Joined:
    Sep 22, 2017
    Posts:
    27
    CreakyVibez likes this.