Why RigidBody3D does not move?

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

I am making a turret.
All nodes with their scenes:

-Turret(Node3D/CSGBox3D - turret.tscn)
  -Gun(Node3D/CSGBox3D - gun.tscn)
    -Bullet(RigidBody3D - bullet.tscn)

Gun:
var bullet_res: PackedScene = preload("res://bullet.tscn")
func fire() -> void:
	var bullet = bullet_res.instantiate()
	bullet.apply_central_impulse(global_transform.basis.x * 10)
	add_child(bullet)

A bullet flies when firing. Everything is fine.
But if I turn the tower:

Turret:
func _process(delta):
  rotate(Vector3.UP, 0)

The bullets do not fly.

Why does Turret.rotate affect the bullet.apply_ central_ impulse ?

:bust_in_silhouette: Reply From: fuck

Moving the rotation from _process to _physics_process should fix this.

However, you should not be adding the bullets as children to gun or turret because then when you move or rotate the gun, the bullet will move/rotate with it and behave strangely. You should instead add the bullets as children of the world node or another stationary node. If you are unfamiliar with the concept of local vs global coordinates, please read: https://forum.godotengine.org/40058/what-is-the-difference-between-global-and-local-coordinates