Using v4.1.3.stable.mono.official [f06b6836a]
Trying to check what Node a raycast has collided with
public bool CheckLOS(Node2D Target)
{
var spaceState = GetWorld2D().DirectSpaceState;
var query = PhysicsRayQueryParameters2D.Create(this.Position, Target.Position);
var result = spaceState.IntersectRay(query);
Object Collider = result["collider"] as Object;
if(Collider == Target)
{
GD.Print("u wot m8");
return true;
}
return false;
}
}
Seeing people do this very easily in gdscript with Collider.Name but haven’t seen any C# examples
Getting anything out of the results dictionary is doing my head in since they’re all Variants. Is there a way to cast these out to compare them with Scene level stuff? I can’t even cast results[“position”] to Vector2 since its not a nullable type