+2 votes

Is it possible to make a RigidBody rotate still using 'apply_impulse'? My attempts resulted on it rotating but moving out of place.

in Engine by (60 points)

2 Answers

+2 votes
Best answer

No. apply_impulse is like poking the object, you can make it spin/rotate but you're always going to impart thrust too.

Godot 3.0 only (I think): If you implement the integrateforces virtual method, you can call applytorqueimpulse on the state object. This should do what you want. see: http://docs.godotengine.org/en/latest/classes/class_rigidbody.html#class-rigidbody-integrate-forces

You could attach the body to a joint (to allow it to rotate only) if you want no movement at all.

Worst case, you can set the linear/angular velocity manually.

by (58 points)
selected by

Worst case, you can set the linear/angular velocity manually.

This is what I am trying to avoid, I asked this because there was no function like 'setappliedtorque' like its 2D counterpart has.

Thanks anyway, one more reason to be hyped for 3.0.

+3 votes

I posted a sample project in the forum which does this (in godot 2.1.3):
https://godotdevelopers.org/forum/discussion/18480/godot-3d-vector-physics-cheat-sheet

physics/vector 3d sample project

In short:
You need to apply impulses on both "ends" in opposite directions. And you should wait a short time (i.e. 0.1sec) after start for physics to settle down before applying impulses.

by (3,278 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.