WIP duck pushing behaviour
This commit is contained in:
@@ -10,13 +10,13 @@ public partial class Duck : Node2D
|
||||
[Export] private AudioPlayer _wingFlapAudio;
|
||||
[Export] private Node2D _vesna;
|
||||
[Export] private float _runningSpeed = 5f;
|
||||
[Export] private float _slowSpeed = 0.5f;
|
||||
[Export] private float _slowSpeed = 1f;
|
||||
[Export] private float _minDistanceToVesna = 1000f;
|
||||
|
||||
private bool _vesnaInReach = false;
|
||||
private bool _penEntered = false;
|
||||
private Vector2 _lastDirection = Vector2.Up;
|
||||
private int _numberOfFramesPerDirection = 100;
|
||||
private int _numberOfFramesPerDirection = 1000;
|
||||
private int _currentFramesThisDirection = 0;
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ public partial class Duck : Node2D
|
||||
{
|
||||
_characterBody.Velocity = Vector2.Zero;
|
||||
_characterBody.MoveAndSlide();
|
||||
GD.Print("Pen entered.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -40,9 +41,10 @@ public partial class Duck : Node2D
|
||||
if (currentDistance < _minDistanceToVesna)
|
||||
{
|
||||
_characterBody.Velocity = new Vector2( _characterBody.GlobalPosition.X - _vesna.GlobalPosition.X,
|
||||
_characterBody.GlobalPosition.Y - _vesna.GlobalPosition.Y);
|
||||
_characterBody.GlobalPosition.Y - _vesna.GlobalPosition.Y).Normalized();
|
||||
_characterBody.Velocity *= _runningSpeed;
|
||||
_characterBody.MoveAndSlide();
|
||||
// todo: Add noise!
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -58,6 +60,13 @@ public partial class Duck : Node2D
|
||||
_characterBody.MoveAndSlide();
|
||||
}
|
||||
|
||||
/*
|
||||
if (_characterBody.Velocity.X < 0 && _characterBody.Scale.X > 0)
|
||||
{
|
||||
_characterBody.Scale = new Vector2(_characterBody.Scale.X * (-1), _characterBody.Scale.Y);
|
||||
}
|
||||
*/
|
||||
|
||||
base._Process(delta);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Animation;
|
||||
|
||||
public partial class PenCollider : Area2D
|
||||
{
|
||||
// bisons vorschlag:
|
||||
|
||||
// duck entered pen -> pen detects collision,
|
||||
// collision reffences somehow to the duck -> pen "catches" duck object -> sets duck "i am your pen now"
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://fvo04di6k7we
|
||||
Reference in New Issue
Block a user