gd: broken weapon throw

This commit is contained in:
2025-06-06 23:21:56 +02:00
parent 579b523a37
commit c2a8b939e8
5 changed files with 72 additions and 16 deletions

View File

@ -2,20 +2,60 @@ using Godot;
namespace Movementtests.systems;
public partial class WeaponSystem : MeshInstance3D
public partial class WeaponSystem : RigidBody3D
{
private Node3D _head;
private ShapeCast3D _dashCast3D;
private Camera3D _camera;
private TweenQueueSystem _tweenQueueSystem;
private Transform3D _startTransform;
private MantleSystem _mantleSystem;
private MeshInstance3D _dashTarget;
private Vector3 _throwDirection;
private Vector3 _plantLocation;
private Vector3 _plantNormal;
public void Init(Node3D head, Camera3D camera, TweenQueueSystem tweenQueueSystem)
public void Init(Node3D head, Camera3D camera)
{
_head = head;
_camera = camera;
_tweenQueueSystem = tweenQueueSystem;
_tweenQueueSystem = GetNode<TweenQueueSystem>("TweenQueueSystem");
_tweenQueueSystem.Init(this);
_startTransform = Transform;
Freeze = true;
}
public void ThrowWeapon(Vector3 start, Vector3 end, bool hasHit, Vector3 collisionLocation, Vector3 collisionNormal)
{
_throwDirection = (end - start).Normalized();
_plantLocation = collisionLocation;
_plantNormal = collisionNormal;
LookAt(GlobalTransform.Origin + _throwDirection);
RotateX(-Mathf.Pi / 2);
var tween = _tweenQueueSystem.TweenToLocation(new TweenQueueSystem.TweenInputs(end, 1f));
if (hasHit)
tween.Finished += PlantWeaponInWall;
else
tween.Finished += ThrowWeaponOnCurve;
}
public void ThrowWeaponOnCurve()
{
Freeze = false;
}
public void PlantWeaponInWall()
{
Position = _plantLocation;
LookAt(_plantLocation + _plantNormal, Vector3.Up);
}
public void ResetWeapon()
{
Transform = _startTransform;
Freeze = true;
}
}