35 lines
640 B
C#
35 lines
640 B
C#
![]() |
using Godot;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using Godot.Collections;
|
||
|
|
||
|
namespace Rokojori
|
||
|
{
|
||
|
|
||
|
[GlobalClass]
|
||
|
public partial class Interactor:Node3D, SensorInputHandler
|
||
|
{
|
||
|
[Export]
|
||
|
public Pointer pointer;
|
||
|
|
||
|
[Export]
|
||
|
public Sensor button;
|
||
|
|
||
|
public void _OnSensor( SensorEvent se )
|
||
|
{
|
||
|
if ( pointer == null || pointer.pointable == null )
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
var interactable = Nodes.Find<Interactable>( pointer.pointable.GetParent() );
|
||
|
|
||
|
if ( interactable == null )
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
Action.Trigger( interactable.onInteraction );
|
||
|
}
|
||
|
}
|
||
|
}
|