44 lines
985 B
C#
44 lines
985 B
C#
|
using Godot;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
|
||
|
|
||
|
namespace Rokojori
|
||
|
{
|
||
|
public class CollisionData
|
||
|
{
|
||
|
public bool hasCollision = false;
|
||
|
public Node collider;
|
||
|
public Vector3 normal;
|
||
|
public Vector3 position;
|
||
|
public Shape3D shape;
|
||
|
public Rid rid;
|
||
|
|
||
|
|
||
|
public void Get( PhysicsRayQueryParameters3D ray, PhysicsDirectSpaceState3D physicsState )
|
||
|
{
|
||
|
var result = physicsState.IntersectRay( ray );
|
||
|
|
||
|
|
||
|
|
||
|
if ( ! result.ContainsKey( "collider" ) )
|
||
|
{
|
||
|
hasCollision = false;
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
hasCollision = true;
|
||
|
|
||
|
|
||
|
|
||
|
collider = result[ "collider" ].As<Node>();
|
||
|
normal = result[ "normal" ].AsVector3();
|
||
|
position = result[ "position" ].AsVector3();
|
||
|
shape = result[ "shape" ].As<Shape3D>();
|
||
|
rid = result[ "rid" ].AsRid();
|
||
|
|
||
|
// RJLog.Log( "Has Collision:", HierarchyName.Of( collider ), ">> at position:", position, "with normal:", normal );
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|