Cannot move and rotate at the same time

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By HahaTheErrorsGoBrr

I tried to make a cube that moves and rotate when clicked

func _physics_process(delta):
set_axis_velocity(-global_transform.basis.z)
if Input.is_action_pressed("click"):
	rotate_y(0.05)

When i started to click and hold my mouse, the object just rotate and not getting affected by gravity nor moving but i want it to fall down and move. But when i released the mouse, the object was be able to fall and move. Is there anyway to make this possible? Sorry for not making this easier to understand, I’m pretty bad at English and this is the best I can get.

:bust_in_silhouette: Reply From: whiteshampoo

Please try this:

# Rotate with physics
add_torque(Vector3(0.0, 1.0, 0.0))

or this:

# Poke your object with physics
apply_torque_impulse(Vector3(0.0, 0.05, 0.0))

instead of:

# Rotate without physics
rotate_y(0.05)