Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rigidbody doesn't rotate when linear movement restriction on all axis is applied #36847

Open
Tracked by #45333
Zuppor opened this issue Mar 6, 2020 · 13 comments
Open
Tracked by #45333

Comments

@Zuppor
Copy link

Zuppor commented Mar 6, 2020

Godot version:
3.2 stable

OS/device including version:
Windows 10

Issue description:
rigidbody wont rotate when the linear movement on all the axis is locked

Steps to reproduce:

  • make a rigidbody
  • attach a collision shape as a child of the rigidbody and select a box shape
  • adjust the collision shape extents and translation, so the parent pivot is on the side of it
  • on the rigidbody, restrict the linear movement on all the axis, and restrict the angular movement on the x and z axis (see image)
  • use a kinematic body as the player (see image)
  • play the scene and try to push the rigidbody with the player: the rigidbody should rotate around its y axis, but it doesn't, instead the player goes trough it
  • now unlock the linear movement on one of the axis of the rigidbody
  • play the scene and try to push again the rigidbody with the player: it should rotate around the y axis, and move along the unlocked axis (except if you unlocked the y axis)

Minimal reproduction project:

IssueExample.zip

@Zuppor Zuppor closed this as completed Mar 6, 2020
@rsubtil
Copy link
Contributor

rsubtil commented Mar 6, 2020

I believe I see your issue: you want to be able to "rotate" the door without it moving "vertically" on the y axis.

I have talked with a friend of mine who studies physics, and from what I understood, you need to always unlock the y axis if you wish to have angular velocity on that axis. So, if you want the door to rotate, you'd have to allow it to move in the Y axis (even though it doesn't make much sense).

I don't know if what I said above is entirely true (I'm no physics expert 😛 ), but tinkering with your project files and looking at the math, it seems like it.

@Zuppor Zuppor reopened this Mar 7, 2020
@Zuppor
Copy link
Author

Zuppor commented Mar 7, 2020

I personally think it doesn't make sense. If I want to just rotate on the y axis without actually moving, why do I have to unlock the linear movement on that axis too?

@rsubtil
Copy link
Contributor

rsubtil commented Mar 7, 2020

I totally agree with you. However, I assume the code works something like this: when you lock the three axis, it means "lock all transformation on the X, Y and Z" axis. Which makes it's impossible to move and/or rotate a door, code-wise.

I think, for your specific case, you need to use an HingeJoint. Now, whether this specific physics scenario makes sense or not in the context of the engine, I have no clue ¯_(ツ)_/¯

@Zuppor
Copy link
Author

Zuppor commented Mar 9, 2020

Yeah, I'm experimenting with the hingejoint already.
But I have to say, I tried to do the same thing within another engine (Unity 3D) and it worked as I expected: the object was not able to move in any direction (as I locked the linear movement on all the axis), but was able to rotate along the y axis (with the angular movement locked on the x and z axis). I think it should be like that in the Godot engine, unless there is something I am ignoring and it works as intended? 🤔

@rsubtil
Copy link
Contributor

rsubtil commented May 19, 2020

@Zuppor a PR was merged (#38852) that might be related to your issue as well, maybe give it another shot?

@akien-mga
Copy link
Member

CC @AndreaCatania to review if #38852 would address this.

@AndreaCatania AndreaCatania self-assigned this May 19, 2020
@AndreaCatania AndreaCatania modified the milestones: 4.0, 3.2 May 19, 2020
@AndreaCatania
Copy link
Contributor

Interesting use case; However, I'm not able to reproduce it in the Godot version 4:
ezgif com-video-to-gif(24)

I don't think the commit #38852 solves this problem (if confirmed) since it seems related to something other. I'm going to test it with version 3.2.

However, double check that the door is not colliding with the ground. This may obstruct the movement.

@AndreaCatania
Copy link
Contributor

I'm not able to reproduce it with the version 3.2 too. Here my sample project, hoping it will be useful to you:
DoorTest.zip

@AndreaCatania AndreaCatania removed this from the 3.2 milestone May 19, 2020
@pouleyKetchoupp
Copy link
Contributor

I can reproduce the issue with the original MRP in 3.2.4 beta 5.

Bullet: The player goes through the door.
Godot physics: The player collides with the door, but the door doesn't move.

@micimize
Copy link

micimize commented Mar 27, 2022

To clarify/reconcile the above repros/vs fail to repo above (on 3.4.3), the demo Andrea posted of two colliding rigid bodies works, but programmed collision from a KinematicBody does not. If infinite_inertia is true the player goes through the door, otherwise they collide but the door doesn't move (with Bullet)

@Zireael07
Copy link
Contributor

@micimize in that case it'll probably get closed, as infinite inertia is no longer a thing in Godot 4.0

@micimize
Copy link

@Zireael07 updated to clarify – infinite_inertia means the difference between no collision and collision-without-motion. I quickly tried patching the initial sample on the latest v4 alpha and it seems to have the same issue, but I don't know the new API very well so maybe just missed something.

I'll also mention that I have been unable to find a workaround with a HingeJoint (or any joint) that prevents the impulses from a KinematicBody from taking a door off it's hinges

@lmsonic
Copy link

lmsonic commented Jul 18, 2023

I tried to reproduce the issue in 4.1.1, converting the 3.x project posted by OP
CharacterBody3D is different from KinematicBody in Godot 3.x and the pushing behavior doesn't come out of the box (was it there originally?), so I setup the door to rotate with angular velocity in Y with linear movement locked on all axis, and angular movement locked in X and Z, it seems to be working, and you can stop it from rotating by putting yourself in the path of door's rotation. If the linear velocity in Y is unlocked, gravity is applied, it collides with the floor and stops rotating.
I'm not sure if this means the issue is fixed or not?
IssueExample.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants