goodbye collisions
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
using System.Linq;
|
||||
|
||||
public partial class Projectile : Node3D
|
||||
{
|
||||
@@ -13,9 +11,14 @@ public partial class Projectile : Node3D
|
||||
[Export]
|
||||
public AudioStream _soundEffect;
|
||||
|
||||
public Character ParentCharacter;
|
||||
[Export]
|
||||
public AudioStream _onHitSfx;
|
||||
|
||||
private Array<Path3D> _paths;
|
||||
[Export]
|
||||
public RigidBody3D _hitBox;
|
||||
|
||||
[Export]
|
||||
public bool HasRotation = false;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
@@ -23,18 +26,28 @@ public partial class Projectile : Node3D
|
||||
var sfxPlayer = GetTree().Root.GetNode<AudioStreamPlayer>("Main/SFXPlayer");
|
||||
sfxPlayer.Stream = _soundEffect;
|
||||
sfxPlayer.Play();
|
||||
_paths = new Array<Path3D>(GetChildren().OfType<Path3D>());
|
||||
}
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
foreach (var paths in _paths)
|
||||
{
|
||||
var pathFollow = paths.GetChildren().OfType<PathFollow3D>().Single();
|
||||
pathFollow.Progress += Speed * (float)delta;
|
||||
if (pathFollow.ProgressRatio > 0.9f)
|
||||
QueueFree();
|
||||
}
|
||||
var pathFollow = GetNode<PathFollow3D>("PathFollow3D");
|
||||
pathFollow.Progress += Speed * (float)delta;
|
||||
if (pathFollow.ProgressRatio > 0.9f)
|
||||
QueueFree();
|
||||
}
|
||||
|
||||
public void OnProjectileHit(Node node)
|
||||
{
|
||||
SetProcess(false);
|
||||
if (node.GetParent() is BasicEnemy basicEnemy && basicEnemy.HasMethod(BasicEnemy.MethodName.OnEnemyHit))
|
||||
basicEnemy.Call(BasicEnemy.MethodName.OnEnemyHit, node);
|
||||
else
|
||||
GD.Print("Hit something other than enemy: " + node.GetParent().Name);
|
||||
_hitBox.QueueFree();
|
||||
|
||||
var sfxPlayer = GetTree().Root.GetNode<AudioStreamPlayer>("Main/SFXPlayer");
|
||||
if (!sfxPlayer.Playing)
|
||||
sfxPlayer.Play();
|
||||
}
|
||||
|
||||
public float Speed { get; private set; }
|
||||
|
||||
Reference in New Issue
Block a user