gd: weapon throws orients and throws itself correctly
This commit is contained in:
@ -4,6 +4,11 @@ namespace Movementtests.systems;
|
||||
|
||||
public partial class WeaponSystem : RigidBody3D
|
||||
{
|
||||
[Export(PropertyHint.Range, "0,100,1,or_greater")]
|
||||
public float ThrowForce { get; set; } = 1f;
|
||||
[Export(PropertyHint.Range, "0,0.2,0.01,or_greater")]
|
||||
public float StraightThrowDuration { get; set; } = 0.1f;
|
||||
|
||||
private Node3D _head;
|
||||
private ShapeCast3D _dashCast3D;
|
||||
private Camera3D _camera;
|
||||
@ -27,15 +32,14 @@ public partial class WeaponSystem : RigidBody3D
|
||||
Freeze = true;
|
||||
}
|
||||
|
||||
public void ThrowWeapon(Vector3 start, Vector3 end, bool hasHit, Vector3 collisionLocation, Vector3 collisionNormal)
|
||||
public void ThrowWeapon(Vector3 end, bool hasHit, Vector3 collisionLocation, Vector3 collisionNormal)
|
||||
{
|
||||
_throwDirection = (end - start).Normalized();
|
||||
_throwDirection = (end - GlobalPosition).Normalized();
|
||||
_plantLocation = collisionLocation;
|
||||
_plantNormal = collisionNormal;
|
||||
LookAt(GlobalTransform.Origin + _throwDirection);
|
||||
RotateX(-Mathf.Pi / 2);
|
||||
LookAt(end);
|
||||
|
||||
var tween = _tweenQueueSystem.TweenToLocation(new TweenQueueSystem.TweenInputs(end, 1f));
|
||||
var tween = _tweenQueueSystem.TweenToLocation(new TweenQueueSystem.TweenInputs(end, StraightThrowDuration));
|
||||
if (hasHit)
|
||||
tween.Finished += PlantWeaponInWall;
|
||||
else
|
||||
@ -45,12 +49,13 @@ public partial class WeaponSystem : RigidBody3D
|
||||
public void ThrowWeaponOnCurve()
|
||||
{
|
||||
Freeze = false;
|
||||
ApplyImpulse(_throwDirection * ThrowForce);
|
||||
}
|
||||
|
||||
public void PlantWeaponInWall()
|
||||
{
|
||||
Position = _plantLocation;
|
||||
LookAt(_plantLocation + _plantNormal, Vector3.Up);
|
||||
GlobalPosition = _plantLocation;
|
||||
LookAt(GlobalTransform.Origin + _plantNormal, Vector3.Up, true);
|
||||
}
|
||||
|
||||
public void ResetWeapon()
|
||||
|
Reference in New Issue
Block a user