Fix Project
This commit is contained in:
@@ -36,14 +36,13 @@ public partial class TestCharacter : CharacterBody3D
|
||||
if (direction != Vector3.Zero)
|
||||
{
|
||||
velocity.X = direction.X * _speed;
|
||||
velocity.Z = direction.Z * _speed;
|
||||
velocity.Z = direction.Z * _speed * 2;
|
||||
GetNode<Node3D>("Pivot").LookAt(Position + direction, Vector3.Forward + Vector3.Up);
|
||||
GetNode<Node3D>("CollisionShape3D").LookAt(Position + direction, Vector3.Forward + Vector3.Up);
|
||||
}
|
||||
else
|
||||
{
|
||||
velocity.X = Mathf.MoveToward(Velocity.X, 0, _speed);
|
||||
velocity.Z = Mathf.MoveToward(Velocity.Z, 0, _speed);
|
||||
velocity.Z = Mathf.MoveToward(Velocity.Z, 0, _speed * 2);
|
||||
}
|
||||
return velocity;
|
||||
}
|
||||
|
||||
17
Scripts/TestEnemy.cs
Normal file
17
Scripts/TestEnemy.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Godot;
|
||||
|
||||
public partial class TestEnemy : Node3D
|
||||
{
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
var player = GetTree().GetFirstNodeInGroup("Player") as TestCharacter;
|
||||
if (player != null)
|
||||
LookAt(player.Position);
|
||||
}
|
||||
|
||||
public void OnHit(Node node)
|
||||
{
|
||||
GD.Print("Hit detected");
|
||||
QueueFree();
|
||||
}
|
||||
}
|
||||
14
Scripts/TestLevel.cs
Normal file
14
Scripts/TestLevel.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using Godot;
|
||||
|
||||
public partial class TestLevel : Node3D
|
||||
{
|
||||
[Export]
|
||||
private Marker3D _spawnPoint;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
var players = GetTree().GetNodesInGroup("Player");
|
||||
foreach (TestCharacter player in players)
|
||||
player.Transform = _spawnPoint.Transform;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user