Rigidbody2D slides on platform if z rotation is abled

I have a Bait object with a Rigidbody2D and a Capsule Collider 2D

This Bait object is launched through a Platform with a Box Collider 2D and a Platform Effector 2D, then the Bait falls and sits on the Platform.

If Freeze Rotation Z is checked, all goes as expected and the Bait stays in the Platform on the place it falls.

On contrary, if Freeze Rotation Z is not checked, the Bait gains speed in it’s Rigidbody and falls. This happens even if I uncheck de Freeze Rotation Z after the Bait succesfully lands on the Platform, the only difference is that Freeze Rotation Z is already unchecked from the start, the Bait bounces in and out of the Platform while it gains speed.

The Bait happens to gain speed in the same direction that is falling, like if the angular force was pushing it.

Both of the object have a material and I changed friction and bounceness without results.

I hope the info is enough. I’ve attached screenshots from the components.

Thanks for your help!


Make sure you have no scripts or animations driving these physics bodies.

If you do, here’s how to do it correctly:

With Physics (or Physics2D), never manipulate the Transform directly. If you manipulate the Transform directly, you are bypassing the physics system and you can reasonably expect glitching and missed collisions and other physics mayhem.

Always use the .MovePosition() and .MoveRotation() methods on the Rigidbody (or Rigidbody2D) instance in order to move or rotate things. Doing this keeps the physics system informed about what is going on.

1 Like

Sorry for the late response, I was working in other things. And thanks for your time.

I tried.

The Bait setup is a spin that I previusly managed with transform. Now I got this:

Quaternion q = Quaternion.AngleAxis(alpha, transform.forward * -1);
rb2d.MovePosition(q * (rb2d.transform.position - handPosition) + handPosition);
rb2d.MoveRotation(rb2d.transform.rotation * q);

The Bait revolves around handPosition and somehow I don’t know how to “release” it as the velocity in the RigidBody2D remains (0,0) with MovePosition as it did with transform changes, so I choose to AddForce when I want to release. On this topic, pointing one of the links you provided, I tried setting the RigidBody2D to Kinematic and AddForce is not showing any effect.

Keeping the release thing apart, the result on the landing is the same.

You can do it a bunch of ways. One way is to compute the circumferential speed from the rotation speed and the radius. That’s the technically schoolboard way.

Another way is to observe the thing every frame as it goes through its arc, keeping the previous frame position.

Upon release, subtract previous frame position from current frame position and that will be the instantaneous circumferential (tangential) motion of the ball. Divide that vector by Time.deltaTime and that should give you the velocity to feed into the Rigidbody to send it along its merry way.

Note that this isn’t the Transform of the Rigidbody2D, it’s just the Transform component i.e. just “transform” as you use above it. All components give you access to the Transform. The Rigidbody2D has its own pose properties for position and rotation which won’t always be the same as the current Transform.

Thanks both of you,

I’m even more confused, but thats learning I supose.

When I try to multiply the Quaternion q with what I think is the float rb3d.rotation VS flags an error that says multiplying that is not possible.

Quaternion q = Quaternion.AngleAxis(alpha, transform.forward * -1);
rb2d.MovePosition(q * (new Vector3(rb2d.position.x, rb2d.position.y) - handPosition) + handPosition);
rb2d.MoveRotation(rb2d.rotation * q);

I will try and update here, it seems plausible that way, thank you!!

And I want to know something, did we drifted into this topic (I’m happy with it anyways, it’s helpful) or it has something to do with the other issue in the landing? I’m trying to understand how those things are connected, given that I’m already using MovePosition, MoveRotation and AddForce.

You can move a Rigidbody just by letting things bump into it.

You can set the Rigidbody velocity and then it does its thing. If you set it every frame, it will try its best to blast through whatever is in its way, if it can be moved.

Or you can compute its new position yourself and tell it to move with MovePosition / MoveRotation, in which case force and velocity are irrelevant.

Or you can add force to it, but if it starts to move and you keep adding the same force, it will accelerate faster and faster until drag compensates and it reaches terminal velocity.

It may be useful to review a basic kinematic physics primer so you can keep the ideas of force, mass, acceleration, velocity and position separate in your mind. They relate but they absolutely are NOT the same thing.

Look at the docs, a 2D rotation is a float because 2D has a single degree of rotational freedom. If you needed to use that as a Quaternion then you’ll need to create a Quaternion from it.

My only point though was to note that by using the Rigidbody2D as a component to get the Transform just gets the Transform. The only other aspect being that when using interpolation, the Transform is not the same as the current Rigidbody2D position/rotation as the Rigidbody2D is already at the position/rotation the Transform is interpolating to.

Well, from both of your explanations I learned a lot, and I appreciate that.

But I have to reverse all this to the beginning, Why is a free moving (after an addforce) rigidbody2d slides and fall of a platform after landing (and even bounces in and out of it while moving)? Even with the correct functions acting on it from the first frame. Or, in contrary, if there is something I’m missing, can I provide some other information that helps? I have so few objects in place, I feel like this is something soooo stupid from me if no one else heard of this

No matter what I will try with a new project and if it works, I’ll keep it, but I’ll hate to do.

Thanks!!

  • I changed the capsule collider 2d with a box collider 2d and it happens too

I don’t know if the words I have to myself are permitted on this forum.

I was not misunderstanding the responses as I belived, but my code.

Oh, I’m almost crying, what a stupid piece of s**t.

I will post it so everyone knows.

transform.up = transform.position - HandController.transform.position;

Thank you!!

I’m not sure I follow you, but just so you understand, when you do this:

when there is a Rigidbody on that Transform, you ARE bypassing physics, as I outlined in my first response above.

It might work, but a better way is to use MoveRotation() to set the new rotation to an angle.

You can get an angle between two vectors using the static Vector2.Angle() method.

1 Like