- Edited
Hi, I want to make an asteroid like race game, and I need to disable the collision rotation of my RigidBody(aka the player) to behave the way I want with the borders of the track. Any idea about how to do so? Thanks
Hi, I want to make an asteroid like race game, and I need to disable the collision rotation of my RigidBody(aka the player) to behave the way I want with the borders of the track. Any idea about how to do so? Thanks
Maybe try setting the mode to character, like suggested in this Q&A post, https://godotengine.org/qa/1843/how-to-disable-rotation-for-a-rigidbody2d, and see if that helps?
It indeed stop the rotation, but in this case the RigidBody2D can no longer be controlled by key Input :/ . I want to disable the physical rotation of the RigidBody, not how it behave with the inputs.
If you are okay with a script solution, you could override the _intergrate_forces
function, and then only set the origin of the RigidBody2D. I have not tested it, but it would be something like this:
func _integrate_forces(state):
# I don't remember if the state transform is local or global. I assumed local
# for now, but you may need to change these to global variables.
# Store the rotation we want to keep
var current_rotation = rotation;
# Set our transform to the state's transform
transform = state.transform
# Undo rotation
rotation = current_rotation
# Set the state's transform to the current transform
state.transform = transform
Your idea have helped me to find the answer. I've used set_applied_torque in order to make the vehicle rotate. By removing it and by setting manually the rotation(with keys), I've ereased the physic rotation behavior against the walls. Thanks a lot