Basic enemy pathing implementation
This commit is contained in:
@@ -36,13 +36,13 @@ public partial class TestCharacter : CharacterBody3D
|
||||
if (direction != Vector3.Zero)
|
||||
{
|
||||
velocity.X = direction.X * _speed;
|
||||
velocity.Z = direction.Z * _speed * 2;
|
||||
GetNode<Node3D>("Pivot").LookAt(Position + direction, Vector3.Forward + Vector3.Up);
|
||||
velocity.Z = direction.Z * _speed;
|
||||
GetNode<Node3D>("Pivot").LookAt(Position + direction, Vector3.Up);
|
||||
}
|
||||
else
|
||||
{
|
||||
velocity.X = Mathf.MoveToward(Velocity.X, 0, _speed);
|
||||
velocity.Z = Mathf.MoveToward(Velocity.Z, 0, _speed * 2);
|
||||
velocity.Z = Mathf.MoveToward(Velocity.Z, 0, _speed);
|
||||
}
|
||||
return velocity;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
using Godot;
|
||||
|
||||
public partial class TestEnemy : Node3D
|
||||
public partial class TestEnemy : RigidBody3D
|
||||
{
|
||||
[Export]
|
||||
private float _speed;
|
||||
[Export]
|
||||
private PathFollow3D _pathFollow;
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
var player = GetTree().GetFirstNodeInGroup("Player") as TestCharacter;
|
||||
@@ -9,6 +14,11 @@ public partial class TestEnemy : Node3D
|
||||
LookAt(player.Position);
|
||||
}
|
||||
|
||||
public override async void _PhysicsProcess(double delta)
|
||||
{
|
||||
_pathFollow.Progress += _speed * (float)delta;
|
||||
}
|
||||
|
||||
public void OnHit(Node node)
|
||||
{
|
||||
GD.Print("Hit detected");
|
||||
|
||||
Reference in New Issue
Block a user