Strange behavior of the engine...

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

Once again, good day to all. I played around with the code a bit and noticed an interesting feature, namely, this code fragment detects an anode from another scene, but does not interact with it. What do you think could be wrong? But if you specify the path to the object directly on the general scene, then everything is fine, but this approach is not necessary in this case. Since the duplicated scenes only work with one scene, that is, " spike “will work, but” Space_2"," Space_3", " … " will not. Therefore, here the approach is to immediately get a collision from the loaded scene. The main question is this. Why is the collision detected (There are no errors in the console), but does not interact with it?

Code:

var LoadSceneSpike_object = Godot.ResourceLoader.Load<PackedScene>("res://Core/Scenes/Spike.tscn");

var SpikeScene_object_loaded = LoadSceneSpike_object.Instance();

var CollisionSpike_Damage = SpikeScene_object_loaded.GetNode<KinematicBody2D>("Spike_body");
if (collision.Collider == CollisionSpike_Damage)
{
  hp = hp - 50;
}