Added robot follow button
This commit is contained in:
@@ -6,6 +6,7 @@ public partial class Camera3d : Camera3D
|
||||
[Export] public float Speed = 7.5f;
|
||||
[Export] public float MouseSensitivity = 0.2f;
|
||||
[Export] public float ScrollStrength = 5.0f;
|
||||
private Robot robot;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
@@ -33,13 +34,27 @@ public partial class Camera3d : Camera3D
|
||||
|
||||
if (direction != Vector3.Zero)
|
||||
{
|
||||
if(robot != null) robot = null;
|
||||
direction = direction.Normalized() * Speed * (Input.IsActionPressed("sprint") ? 2.5f : 1) * d;
|
||||
Translate(direction);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(robot != null)
|
||||
{
|
||||
Position = new Vector3(robot.Position.X, 10 - visibleLayer * 4, robot.Position.Z + 4f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (Position.Y != 10 - visibleLayer * 4)
|
||||
{
|
||||
Position = new Vector3(Position.X, 10 - visibleLayer * 4, Position.Z);
|
||||
}
|
||||
}
|
||||
|
||||
public void Follow(Robot robot)
|
||||
{
|
||||
this.robot = robot;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user