![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | rico345100 |
Here’s the code for spawning object which is rigidbody node:
func spawn_asteroid():
var spawn_position: Vector3 = get_spawn_position()
var asteroid_instance = asteroid_scene.instance()
asteroid_instance.transform.origin = spawn_position
spawned_asteroids.append(asteroid_instance)
# Push towards player
var direction_to_player: Vector3 = player.transform.origin - spawn_position
asteroid_instance.add_force(direction_to_player * asteroid_speed, spawn_position)
add_child(asteroid_instance)
There’s no add_torque or any additional codes to handle rotation, however when object spawned, it spins like spinning top.
First I thought that it caused if two rigidbody objects are intersected and push each other and cause rotation, but it wasn’t.
Have no idea why they are spinning. Is there a something that I missed? Unlike Unity, there’s no way to stop their rotation. Using Godot 3.1.1.