Partial Completion of Tutorial
This commit is contained in:
parent
0bee2ee47b
commit
cd0f25c73b
6 changed files with 517 additions and 6 deletions
40
Library/Characters/CharacterCollisionRayCast.cs
Normal file
40
Library/Characters/CharacterCollisionRayCast.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
using Godot;
|
||||
using PokemonLike.Library.Support;
|
||||
|
||||
namespace PokemonLike.Library.Characters;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class CharacterCollisionRayCast : RayCast2D
|
||||
{
|
||||
[Signal] public delegate void CollisionEventHandler(bool collided);
|
||||
|
||||
[ExportCategory("Collision Vars")] [Export]
|
||||
public CharacterInput CharacterInput;
|
||||
[Export] public GodotObject Collider;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
Logger.Info("Loading character collision raycast ...");
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (TargetPosition != CharacterInput.TargetPosition)
|
||||
TargetPosition = CharacterInput.TargetPosition;
|
||||
|
||||
if (IsColliding())
|
||||
{
|
||||
Collider = GetCollider();
|
||||
string colliderType = Collider.GetType().Name;
|
||||
switch (colliderType)
|
||||
{
|
||||
|
||||
default:
|
||||
EmitSignal(SignalName.Collision, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
EmitSignal(SignalName.Collision, false);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue