gd: weapon throws orients and throws itself correctly
This commit is contained in:
@ -125,6 +125,7 @@ offset_left = 840.0
|
|||||||
offset_top = 1.0
|
offset_top = 1.0
|
||||||
offset_right = -2.0
|
offset_right = -2.0
|
||||||
offset_bottom = 1.0
|
offset_bottom = 1.0
|
||||||
|
enabled = false
|
||||||
initial_node_to_watch = NodePath("../StateChart")
|
initial_node_to_watch = NodePath("../StateChart")
|
||||||
|
|
||||||
[node name="StateChart" type="Node" parent="."]
|
[node name="StateChart" type="Node" parent="."]
|
||||||
@ -186,7 +187,8 @@ delay_in_seconds = "0.0"
|
|||||||
[node name="WeaponRoot" type="Node3D" parent="."]
|
[node name="WeaponRoot" type="Node3D" parent="."]
|
||||||
|
|
||||||
[node name="WeaponSystem" parent="WeaponRoot" instance=ExtResource("29_wv70j")]
|
[node name="WeaponSystem" parent="WeaponRoot" instance=ExtResource("29_wv70j")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 0.984902, 0.173115, 0, -0.173115, 0.984902, 0.45268, 1.44035, -0.692528)
|
transform = Transform3D(1, 0, 0, 0, 0.173648, -0.984808, 0, 0.984808, 0.173648, 0.45268, 1.44035, -0.692528)
|
||||||
|
ThrowForce = 25.0
|
||||||
|
|
||||||
[connection signal="input_aim_canceled" from="InputController" to="." method="OnInputAimCanceled"]
|
[connection signal="input_aim_canceled" from="InputController" to="." method="OnInputAimCanceled"]
|
||||||
[connection signal="input_aim_pressed" from="InputController" to="." method="OnInputAimPressed"]
|
[connection signal="input_aim_pressed" from="InputController" to="." method="OnInputAimPressed"]
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using Godot;
|
using Godot;
|
||||||
using GodotStateCharts;
|
using GodotStateCharts;
|
||||||
using Movementtests.systems;
|
using Movementtests.systems;
|
||||||
@ -152,11 +153,28 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
|
|
||||||
public void OnWeaponThrown()
|
public void OnWeaponThrown()
|
||||||
{
|
{
|
||||||
|
RemoveChild(WeaponRoot);
|
||||||
|
GetTree().GetRoot().AddChild(WeaponRoot);
|
||||||
|
WeaponRoot.SetGlobalPosition(GlobalPosition);
|
||||||
|
|
||||||
var (hasHit, location, collisionPoint, collisionNormal) = DashSystem.DashComputation;
|
var (hasHit, location, collisionPoint, collisionNormal) = DashSystem.DashComputation;
|
||||||
var (endWithMantle, dashLocation, mantleLocation) = DashSystem.DashResolve;
|
var (endWithMantle, dashLocation, mantleLocation) = DashSystem.DashResolve;
|
||||||
WeaponSystem.ThrowWeapon(Position, dashLocation, hasHit, collisionPoint, collisionNormal);
|
|
||||||
DashSystem.CancelDash();
|
DashSystem.CancelDash();
|
||||||
// RemoveChild(WeaponSystem);
|
WeaponSystem.ThrowWeapon(location, hasHit, collisionPoint, collisionNormal);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnDashEnded()
|
||||||
|
{
|
||||||
|
// Generates an error when dashing normally
|
||||||
|
// This should solve itself when we handle weapon thrown dashes and regular dashes through different states
|
||||||
|
GetTree().GetRoot().RemoveChild(WeaponRoot);
|
||||||
|
AddChild(WeaponRoot);
|
||||||
|
|
||||||
|
WeaponRoot.SetGlobalPosition(GlobalPosition);
|
||||||
|
WeaponSystem.ResetWeapon();
|
||||||
|
|
||||||
|
_playerState.SendEvent("dash_ended");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnInputMove(Vector3 value)
|
public void OnInputMove(Vector3 value)
|
||||||
@ -192,13 +210,6 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
{
|
{
|
||||||
_playerState.SendEvent("hit_pressed");
|
_playerState.SendEvent("hit_pressed");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnDashEnded()
|
|
||||||
{
|
|
||||||
_playerState.SendEvent("dash_ended");
|
|
||||||
// AddChild(WeaponSystem);
|
|
||||||
WeaponSystem.ResetWeapon();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnInputJumpPressed()
|
public void OnInputJumpPressed()
|
||||||
{
|
{
|
||||||
@ -211,13 +222,13 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
|
|
||||||
public override void _PhysicsProcess(double delta)
|
public override void _PhysicsProcess(double delta)
|
||||||
{
|
{
|
||||||
WeaponRoot.SetRotation(HeadSystem.Rotation);
|
|
||||||
|
|
||||||
var isPlayerDead = HealthSystem.IsDead();
|
var isPlayerDead = HealthSystem.IsDead();
|
||||||
var isHeadTouchingCeiling = IsHeadTouchingCeiling();
|
var isHeadTouchingCeiling = IsHeadTouchingCeiling();
|
||||||
|
|
||||||
TweenQueueSystem.ProcessTweens();
|
TweenQueueSystem.ProcessTweens();
|
||||||
|
|
||||||
|
if (_weaponInHand.Active || _aiming.Active)
|
||||||
|
WeaponRoot.SetRotation(HeadSystem.Rotation);
|
||||||
if (_aiming.Active)
|
if (_aiming.Active)
|
||||||
DashSystem.PrepareDash();
|
DashSystem.PrepareDash();
|
||||||
|
|
||||||
|
@ -75,7 +75,9 @@ public partial class DashSystem: Node3D
|
|||||||
shouldMantle = mantleResult.IsSome(out mantleLocation);
|
shouldMantle = mantleResult.IsSome(out mantleLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
var targetColor = shouldMantle ? new Color(0.2f, 0.2f, 1f) : new Color(1f, 1f, 1f);
|
var targetColor = hasHit ? new Color(1f, 0.2f, 0.2f) : new Color(1f, 1f, 1f);
|
||||||
|
targetColor = shouldMantle ? new Color(0.2f, 0.2f, 1f) : targetColor;
|
||||||
|
|
||||||
var targetMaterial = (StandardMaterial3D) _dashTarget.GetSurfaceOverrideMaterial(0);
|
var targetMaterial = (StandardMaterial3D) _dashTarget.GetSurfaceOverrideMaterial(0);
|
||||||
targetMaterial.SetAlbedo(targetColor);
|
targetMaterial.SetAlbedo(targetColor);
|
||||||
_dashTarget.SetVisible(true);
|
_dashTarget.SetVisible(true);
|
||||||
@ -106,4 +108,14 @@ public partial class DashSystem: Node3D
|
|||||||
_tweenQueueSystem.QueueTween(DashResolve.MantleLocation, 0.2f);
|
_tweenQueueSystem.QueueTween(DashResolve.MantleLocation, 0.2f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DashToThrownWeapon()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DashToPlantedWeapon()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
[ext_resource type="PackedScene" uid="uid://wq1okogkhc5l" path="res://systems/mantle/mantle_system.tscn" id="2_pff7b"]
|
[ext_resource type="PackedScene" uid="uid://wq1okogkhc5l" path="res://systems/mantle/mantle_system.tscn" id="2_pff7b"]
|
||||||
|
|
||||||
[sub_resource type="SphereShape3D" id="SphereShape3D_qu4wy"]
|
[sub_resource type="SphereShape3D" id="SphereShape3D_qu4wy"]
|
||||||
|
radius = 0.1
|
||||||
|
|
||||||
[sub_resource type="SphereMesh" id="SphereMesh_qu4wy"]
|
[sub_resource type="SphereMesh" id="SphereMesh_qu4wy"]
|
||||||
|
|
||||||
@ -15,7 +16,7 @@ script = ExtResource("1_hwig2")
|
|||||||
[node name="DashCast3D" type="ShapeCast3D" parent="."]
|
[node name="DashCast3D" type="ShapeCast3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.68, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.68, 0)
|
||||||
shape = SubResource("SphereShape3D_qu4wy")
|
shape = SubResource("SphereShape3D_qu4wy")
|
||||||
target_position = Vector3(0, 0, -20)
|
target_position = Vector3(0, 0, -12)
|
||||||
max_results = 1
|
max_results = 1
|
||||||
collision_mask = 2
|
collision_mask = 2
|
||||||
debug_shape_custom_color = Color(0.911631, 0.11884, 0.656218, 1)
|
debug_shape_custom_color = Color(0.911631, 0.11884, 0.656218, 1)
|
||||||
|
@ -22,7 +22,7 @@ debug_shape_custom_color = Color(1, 0, 0, 1)
|
|||||||
[node name="WallInFrontCast3D" type="ShapeCast3D" parent="."]
|
[node name="WallInFrontCast3D" type="ShapeCast3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||||
shape = SubResource("CapsuleShape3D_qu4wy")
|
shape = SubResource("CapsuleShape3D_qu4wy")
|
||||||
target_position = Vector3(0, 0, -2)
|
target_position = Vector3(0, 0, -1.5)
|
||||||
max_results = 1
|
max_results = 1
|
||||||
collision_mask = 2
|
collision_mask = 2
|
||||||
debug_shape_custom_color = Color(0.911631, 0.11884, 0.656218, 1)
|
debug_shape_custom_color = Color(0.911631, 0.11884, 0.656218, 1)
|
||||||
|
@ -4,6 +4,11 @@ namespace Movementtests.systems;
|
|||||||
|
|
||||||
public partial class WeaponSystem : RigidBody3D
|
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 Node3D _head;
|
||||||
private ShapeCast3D _dashCast3D;
|
private ShapeCast3D _dashCast3D;
|
||||||
private Camera3D _camera;
|
private Camera3D _camera;
|
||||||
@ -27,15 +32,14 @@ public partial class WeaponSystem : RigidBody3D
|
|||||||
Freeze = true;
|
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;
|
_plantLocation = collisionLocation;
|
||||||
_plantNormal = collisionNormal;
|
_plantNormal = collisionNormal;
|
||||||
LookAt(GlobalTransform.Origin + _throwDirection);
|
LookAt(end);
|
||||||
RotateX(-Mathf.Pi / 2);
|
|
||||||
|
|
||||||
var tween = _tweenQueueSystem.TweenToLocation(new TweenQueueSystem.TweenInputs(end, 1f));
|
var tween = _tweenQueueSystem.TweenToLocation(new TweenQueueSystem.TweenInputs(end, StraightThrowDuration));
|
||||||
if (hasHit)
|
if (hasHit)
|
||||||
tween.Finished += PlantWeaponInWall;
|
tween.Finished += PlantWeaponInWall;
|
||||||
else
|
else
|
||||||
@ -45,12 +49,13 @@ public partial class WeaponSystem : RigidBody3D
|
|||||||
public void ThrowWeaponOnCurve()
|
public void ThrowWeaponOnCurve()
|
||||||
{
|
{
|
||||||
Freeze = false;
|
Freeze = false;
|
||||||
|
ApplyImpulse(_throwDirection * ThrowForce);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PlantWeaponInWall()
|
public void PlantWeaponInWall()
|
||||||
{
|
{
|
||||||
Position = _plantLocation;
|
GlobalPosition = _plantLocation;
|
||||||
LookAt(_plantLocation + _plantNormal, Vector3.Up);
|
LookAt(GlobalTransform.Origin + _plantNormal, Vector3.Up, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetWeapon()
|
public void ResetWeapon()
|
||||||
|
@ -13,14 +13,14 @@ bottom_radius = 0.05
|
|||||||
height = 1.0
|
height = 1.0
|
||||||
|
|
||||||
[node name="Weapon" type="RigidBody3D"]
|
[node name="Weapon" type="RigidBody3D"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)
|
|
||||||
script = ExtResource("1_csqwk")
|
script = ExtResource("1_csqwk")
|
||||||
|
|
||||||
[node name="TweenQueueSystem" parent="." instance=ExtResource("2_x1nha")]
|
[node name="TweenQueueSystem" parent="." instance=ExtResource("2_x1nha")]
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)
|
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0)
|
||||||
shape = SubResource("CylinderShape3D_avini")
|
shape = SubResource("CylinderShape3D_avini")
|
||||||
|
|
||||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0)
|
||||||
mesh = SubResource("CylinderMesh_x1nha")
|
mesh = SubResource("CylinderMesh_x1nha")
|
||||||
|
Reference in New Issue
Block a user