gd,fix: player won't go through thin platforms from underneath, added a small cooldown to dash actions, remapped inputs a bit for gamefeel

This commit is contained in:
2025-06-20 11:55:19 +02:00
parent 826eaac10c
commit 3a761fd0bd
9 changed files with 151 additions and 48 deletions

View File

@ -1,3 +1,4 @@
using System;
using Godot;
using GodotStateCharts;
@ -23,9 +24,8 @@ public partial class WeaponSystem : RigidBody3D
private Transform3D _startTransform;
private Vector3 _throwDirection;
private Vector3 _plantLocation;
private Vector3 _plantNormal;
public Vector3 PlayerDashLocation { get; set; }
public Vector3 PlantLocation { get; set; }
public Vector3 PlantNormal { get; set; }
public void Init(Node3D head, Camera3D camera)
{
@ -51,8 +51,8 @@ public partial class WeaponSystem : RigidBody3D
_weaponState.SendEvent("throw");
_throwDirection = (end - GlobalPosition).Normalized();
_plantLocation = collisionLocation;
_plantNormal = collisionNormal;
PlantLocation = collisionLocation;
PlantNormal = collisionNormal;
LookAt(end);
var tween = _tweenQueueSystem.TweenToLocation(new TweenQueueSystem.TweenInputs(end, StraightThrowDuration));
@ -72,9 +72,13 @@ public partial class WeaponSystem : RigidBody3D
{
_weaponState.SendEvent("plant");
Freeze = true;
GlobalPosition = _plantLocation;
PlayerDashLocation = ComputeDashLocation(_plantLocation, _plantNormal);
LookAt(GlobalTransform.Origin + _plantNormal, Vector3.Up, true);
GlobalPosition = PlantLocation;
LookAt(GlobalTransform.Origin + PlantNormal, Vector3.Up, true);
}
public void OnThrownWeaponReachesGround(Node other)
{
PlantWeaponInWall();
}
public void ResetWeapon()
@ -83,26 +87,25 @@ public partial class WeaponSystem : RigidBody3D
Transform = _startTransform;
Freeze = true;
}
private Vector3 ComputeDashLocation(Vector3 collisionLocation, Vector3 collisionNormal)
{
return collisionLocation + collisionNormal * 0.2f;
}
public override void _IntegrateForces(PhysicsDirectBodyState3D state)
{
base._IntegrateForces(state);
PlayerDashLocation = GlobalPosition;
if (!Freeze && state.GetContactCount() > 0)
{
_plantLocation = state.GetContactLocalPosition(0);
_plantNormal = state.GetContactLocalNormal(0);
PlayerDashLocation = ComputeDashLocation(_plantLocation, _plantNormal);
PlantLocation = state.GetContactLocalPosition(0);
PlantNormal = state.GetContactLocalNormal(0);
}
}
public void OnThrownWeaponReachesGround(Node other)
public bool IsPlantedUnderPlatform()
{
PlantWeaponInWall();
return PlantedState.Active && GlobalRotation.X > 1 && Math.Abs(GlobalRotation.Y) > 1;
}
public bool IsPlantedInWall()
{
return PlantedState.Active && Math.Abs(GlobalRotation.X) + Math.Abs(GlobalRotation.Z) < 0.3;
}
}