43 lines
761 B
C#
43 lines
761 B
C#
|
|
using Godot;
|
|
using Rokojori;
|
|
|
|
namespace GameJam
|
|
{
|
|
[GlobalClass]
|
|
public partial class MoveForward:Node
|
|
{
|
|
[Export]
|
|
public Node3D player;
|
|
|
|
[Export]
|
|
public RJSensor up;
|
|
|
|
[Export]
|
|
public RJSensor down;
|
|
|
|
[Export]
|
|
public RJSensor left;
|
|
|
|
[Export]
|
|
public RJSensor right;
|
|
|
|
[Export]
|
|
public float speed;
|
|
|
|
public override void _Process( double delta )
|
|
{
|
|
var y = up.GetValue() - down.GetValue();
|
|
var x = right.GetValue() - left.GetValue();
|
|
|
|
var amount = new Vector2( x, y ).Length();
|
|
|
|
amount = Mathf.Max( amount - 0.1f, 0f );
|
|
|
|
amount = amount * (float)delta * speed;
|
|
player.GlobalPosition = player.GlobalPosition + player.GlobalBasis.Z * amount;
|
|
|
|
}
|
|
|
|
}
|
|
} |