1
0
mirror of https://github.com/CLfamilaris/VRDOM.git synced 2024-11-11 22:47:09 +01:00
VRDOM/scripts/ActionHandler.cs

41 lines
964 B
C#
Raw Permalink Normal View History

2023-08-04 23:07:24 +02:00
using Godot;
using System;
public partial class ActionHandler : Node
{
[Export]
private Node3D _leftHand;
2023-08-04 23:07:24 +02:00
[Export]
private Node3D _rightHand;
2023-08-04 23:07:24 +02:00
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
}
public void OnXRButtonPress(string name)
{
GD.Print("Action pressed: " + name);
if (name == "recalibrate")
{
Recalibrate();
}
}
private void Recalibrate()
{
GD.Print("Recalibrating hands");
const float defaultFootHeight = 0.038f;
_leftHand.GlobalRotation = Vector3.Zero;
_rightHand.GlobalRotation = Vector3.Zero;
2023-08-04 23:07:24 +02:00
_leftHand.GlobalPosition = new Vector3(_leftHand.GlobalPosition.X, defaultFootHeight, _leftHand.GlobalPosition.Z);
_rightHand.GlobalPosition = new Vector3(_rightHand.GlobalPosition.X, defaultFootHeight, _rightHand.GlobalPosition.Z);
2023-08-04 23:07:24 +02:00
}
}