Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question "Push Back" when hidding Kinematic Rigidbodies which are moved via transform.Translate()

Discussion in 'Physics' started by Der_Knob, Mar 20, 2023.

  1. Der_Knob

    Der_Knob

    Joined:
    Feb 5, 2018
    Posts:
    34
    Hey,

    I'm currently wondering if it is possible to get "pushed" back, when the player hits an Kinematic Rigidbodies which are moved via transform.Translate().

    More details:
    I have an arcade racing game. There are moving "NPCs" like trains. Those are moved along the rail tracks, and should not be "kicked over". Means, that the hit of the player should not affect the train in any way. But - of course - the player should be impacted by the train.
    If the player stands on the rail track and is hit by the train, he is not "pushed away". Rather slowly moved back or forward until he is no longer inside the train.

    Screenshot 2023-03-20 101125.png
    I already tried, to add force to the train rigidbody. But I assume, as it is Kinematic, it is not working...

    Any idea, where I should look at? Sorry, I'm a little bit lost. Maybe I just need a push in the right direction :)
     
  2. Der_Knob

    Der_Knob

    Joined:
    Feb 5, 2018
    Posts:
    34
    Mh, I somehow got it working. I apply a force to the Kinematic Rigidbody via AddForce(). But I needed to do it in Update() and not in FixedUpdate().
    Not sure why that was the solution. Maybe because the Rigidbody is set collision detection = continuous
     
  3. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,589
    You cannot apply forces to a Kinematic body, that's the whole point of it. It doesn't respond to forces, doesn't have any collision response nor gravity.