@bitshift-r said:
Your code would have to keep track... something like this:
var captured_crystal = null
func _ready() -> void:
$Area.connect("body_entered", self, "_on_body_entered")
func _on_body_entered(body: Node) -> void:
if captured_crystal == null:
captured_crystal = body
else:
# we've already captured a crystal... apply an impulse to body to push it away
pass
Keep in mind that you shouldn't directly move a RigidBody. You should apply impulses. Alternatively you could use the crystal's _integrate_forces to manually steer it towards the center of the ring/area.
On what do I use the code? On the Area itself?
What does "captured_crystal = body" mean? Is "body" a new state given to captured_crystal and can be replaced with 1 or anything else to declare it has been captured?
I'm new to coding in Godot, so I don't know where I have to mention the White_Crystal model. Do I use "$White_Crystal" if I want to refer to any instance of the original? Shouldn't captured_crystal variable be added to the White_Crystal by the Area?
I want to go with the _integrate_forces, but I don't know which tutorial to follow to figure out how to use those. I found this one, but not sure if it's useful for my case:
Also, how will I compare if crystal's x, y and z coordinates are equal to Area.0.0.0 coordinates in order to stop telling it to travel their way? I cannot figure out even how to tell it to travel toward those points, because the crystal can be at -Area.x or +Area.x side, and so on for any axis.