added enemy inputs as a resource
This commit is contained in:
@@ -7,8 +7,8 @@ public partial class FirstEnemy : CharacterBody3D
|
||||
[Export]
|
||||
public Node3D Target { get; set; }
|
||||
|
||||
[Export(PropertyHint.Range, "0,10,0.1,or_greater")]
|
||||
public float Speed = 5.0f;
|
||||
[Export]
|
||||
public EnemyInitInputs Inputs;
|
||||
|
||||
private RayCast3D _wallInFrontRayCast;
|
||||
|
||||
@@ -26,11 +26,11 @@ public partial class FirstEnemy : CharacterBody3D
|
||||
LookAt(targetPlane);
|
||||
|
||||
var velocity = Velocity;
|
||||
velocity.X = direction.X * Speed;
|
||||
velocity.Z = direction.Z * Speed;
|
||||
velocity.X = direction.X * Inputs.Speed;
|
||||
velocity.Z = direction.Z * Inputs.Speed;
|
||||
|
||||
if (_wallInFrontRayCast.IsColliding())
|
||||
velocity.Y = Speed;
|
||||
velocity.Y = Inputs.Speed;
|
||||
else if (!IsOnFloor())
|
||||
velocity += GetGravity() * (float)delta;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user