Ruby's Adventure: Ruby constantly pushed after collision with enemy robot

Edit: Setting Body Type to kinematic does not fix the problem. See my answer below.

Edit: See my other answer below for a solution that actually works.

Prior to posting this, I searched the forum and the internet and I think I found a solution to my problem. I'm posting this nonetheless because I think others might struggle too and because I am not sure if my fix is correct or has any implications I am not aware of.

I am following the awesome tutorial Ruby's Adventure: 2D Beginner and noticed a problem while playtesting: When Ruby collides with a robot she gets pushed away and somehow the force keeps pushing her long after she lost contact with the robot.

I found out that changing Body Type of Ruby's Rigidbody 2D component from Dynamic to Kinematic solves the problem. I searched the tutorial to see if I missed the step where I was told to set the type to kinematic and I could not find it. Did I miss something?

I created a screen recording to help clarify what I am seeing:


Is my fix the correct solution for the problem? Did I miss something in the tutorial or is the tutorial even missing something?

[quote=“ngrash”, post:1, topic: 868270]
Prior to posting this, I searched the forum and the internet and I think I found a solution to my problem. I’m posting this nonetheless because I think others might struggle too and because I am not sure if my fix is correct or has any implications I am not aware of.

I am following the awesome tutorial Ruby’s Adventure: 2D Beginner and noticed a problem while playtesting: When Ruby collides with a robot she gets pushed away and somehow the force keeps pushing her long after she lost contact with the robot.

I found out that changing Body Type of Ruby’s Rigidbody 2D component from Dynamic to Kinematic solves the problem. I searched the tutorial to see if I missed the step where I was told, to set the type to kinematic and I could not find it. Did I miss something?

I created a screen recording to help clarify what I am seeing:
https://www.youtube.com/watch?v=MfJQsET4H9k

Is my fix the correct solution for the problem? Did I miss something in the tutorial or is the tutorial even missing something?
[/quote]
Well done for sorting it but I don’t think it’s you that’s missing anything it’s the tutorial itself that’s ever so slightly out of date.

1 Like

I just realized that setting Body Type to kinematic disables collision checking with all objects except the robot, so my solution does not really work. What else could I try?

You might want to review and post on this thread https://discussions.unity.com/t/739576

1 Like

Reading more about the Rigidbody 2D in the excellent documentation, I found the Linear Drag property. Setting it to 10 (default was 0) fixes the problem nicely.

This makes sense to me. Since I disabled gravity (by setting Gravity Scale to 0) as the tutorial suggests, there is nothing stopping Ruby from floating endlessly when she gets momentum. I think of it like an object in outer space that is missing any form of drag and therefore never comes to a halt. By simulating drag Ruby will still be pushed but comes to a halt shortly after the pushing force stops which makes for a nice effect of being pushed around by the robot.

I still wonder why I could not find a solution in the tutorial and why the problem is not mentioned in the mega thread (thanks @JeffDUnity3D for pointing me towards it).