Search Unity

Redirecting A Force

Discussion in 'Editor & General Support' started by salmonmondays, Dec 7, 2020.

  1. salmonmondays

    salmonmondays

    Joined:
    Nov 12, 2020
    Posts:
    17
    Hey Everyone,

    I am a beginner but have had previous experience in simpler programs such as Scratch. For the game I am making, one of the main mechanics is to redirect the direction a force is being applied on an object. I am wondering two things: Should I go the route of redirecting an object's vector (direction) or have the player apply a bigger force in the direction they are facing? And my second question is how I could do this (answer to the question above)?
    Thank you for your help!
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    If you want it to instantly snap to moving in a different direction, I'd probably go the route of just setting the direction directly. If you want it to slow down to a stop, then accelerate in a different direction over time, I'd use AddForce. If you're looking to create a bounce effect when an object hits another object, I'd try using physics materials with "bounciness" set to 1 and see if you get the desired effect from letting the physics engine do all the work.
    https://docs.unity3d.com/2019.3/Documentation/Manual/class-PhysicMaterial.html
     
  3. salmonmondays

    salmonmondays

    Joined:
    Nov 12, 2020
    Posts:
    17
    Thanks, but I ran into a problem when introducing a slow-motion mechanic to my game (another feature). Whenever I set timeScale to lower than 1 and let it increase to 1 through a matter of 3 seconds, my player mechanics (jumping and movement) are messed up after it returns back to a timeScale of 1. Any ideas on how to fix this?
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    You'll probably need to post the code and be more specific about the problem than "are messed up" for anyone to be able to help here.
     
  5. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,911
    This suggests you have a bug in your player movement code. It's hard to say what the problem is with it unless you share your code here.
     
    Joe-Censored likes this.