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. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    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:
    28
    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:
    28
    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:
    9,413
    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.