Basic pathfinding working for crying ghosts

This commit is contained in:
2026-01-17 23:37:33 -06:00
parent dd4ce5fcf4
commit 3a63bb6709
46 changed files with 691 additions and 34 deletions

View File

@@ -0,0 +1,29 @@
using Godot;
using System;
public partial class Fireballv3 : ProjectileBase
{
[Export] public float TurnSpeed { get; set; }
Vector2 _velocity;
public override void _Ready()
{
base._Ready();
var direction = (GetGlobalMousePosition() - GlobalPosition).Normalized();
_velocity = direction * Speed;
Rotation = _velocity.Angle();
}
public override void _PhysicsProcess(double delta)
{
var targetDirection = (GetGlobalMousePosition() - GlobalPosition).Normalized();
var currentDirection = _velocity.Normalized();
var newDirection = currentDirection.Lerp(targetDirection, TurnSpeed * (float)delta).Normalized();
_velocity = newDirection * Speed;
GlobalPosition += _velocity * (float)delta;
Rotation = _velocity.Angle();
}
}