Compare commits

...

2 Commits

Author SHA1 Message Date
f2a39316ba shader changes that don't do anything
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 19s
Create tag and build when new code gets to main / Export (push) Successful in 9m48s
2026-01-07 17:11:49 +01:00
fffd8c947b implementing jump input buffering on grounded
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 18s
Create tag and build when new code gets to main / Export (push) Successful in 9m47s
2026-01-07 09:58:18 +01:00
4 changed files with 38 additions and 6 deletions

View File

@@ -0,0 +1,10 @@
[gd_resource type="VisualShader" format=3 uid="uid://ce18qeqecjf4w"]
[resource]
code = "shader_type spatial;
render_mode blend_mix, depth_draw_opaque, depth_test_default, cull_back, diffuse_lambert, specular_schlick_ggx;
"
nodes/fragment/0/position = Vector2(280, 0)

View File

@@ -28,6 +28,7 @@ uniform float heightScale = 1.0;
varying vec3 worldPos;
varying vec3 worldNormal;
varying vec3 diffuse;
void vertex() {
@@ -177,12 +178,14 @@ void fragment() {
// sample and output
SPECULAR = specular;
ALBEDO = triplanarSample(texCoordX, texCoordY, texCoordZ, blend, yDot).rgb;
diffuse = ALBEDO;
ROUGHNESS = triplanarRoughness(texCoordX, texCoordY, texCoordZ, blend, yDot).r;
NORMAL = mix(worldNormal, triplanarNormal(yDot, texCoordX, texCoordY, texCoordZ, blend), normalMapStrength);
NORMAL = normalize((VIEW_MATRIX * vec4(NORMAL, 0.0)).xyz);
}
//void light() {
// // Called for every pixel for every light affecting the material.
// // Uncomment to replace the default light processing function with this one.
//}
void light() {
float lambert = dot(NORMAL, LIGHT);
float halfLambert = pow(lambert*0.5 + 0.5, 2);
DIFFUSE_LIGHT = halfLambert * ATTENUATION * LIGHT_COLOR / PI;
}

View File

@@ -69,6 +69,7 @@ Weight = 4.0
MantleTime = 0.3
MantlePath = ExtResource("2_6lejt")
CoyoteTime = 0.3
InputBufferFrames = 5
SimpleJumpStartVelocity = 6.0
SimpleJumpHangTimeInFrames = 1
SimpleJumpGravityLesseningFactor = 2.0

View File

@@ -89,6 +89,8 @@ public partial class PlayerController : CharacterBody3D
[ExportGroup("Jump")]
[Export(PropertyHint.Range, "0,1,0.01")]
public float CoyoteTime { get; set; } = 0.2f;
[Export(PropertyHint.Range, "0,10,1,or_greater")]
public int InputBufferFrames { get; set; } = 3;
// Simple jump
[ExportSubgroup("Simple jump")]
@@ -229,6 +231,8 @@ public partial class PlayerController : CharacterBody3D
private Transition _onLeaveWallFromRunCoyote;
private Transition _onLeaveWallFromRun;
private int _currentJumpBufferFrames = 0;
private float _playerHeight;
private float _playerRadius;
private bool _isJumpInputPressed;
@@ -466,6 +470,12 @@ public partial class PlayerController : CharacterBody3D
if (_simpleDashCooldownTimer.IsStopped())
_simpleDashCooldownTimer.Start();
if (_currentJumpBufferFrames > 0)
{
_currentJumpBufferFrames = 0;
PerformJump();
}
}
public void DashCooldownTimeout()
@@ -639,7 +649,13 @@ public partial class PlayerController : CharacterBody3D
// Jump
public void OnInputJumpStarted()
{
_currentJumpBufferFrames = InputBufferFrames;
_isJumpInputPressed = true;
PerformJump();
}
public void PerformJump()
{
if (MantleSystem.IsMantlePossible)
{
_playerState.SendEvent("mantle");
@@ -870,8 +886,8 @@ public partial class PlayerController : CharacterBody3D
SetVerticalVelocity(Velocity.Y - 2.0f);
}
// Move back to Airborne state management when starting to go down again
if (_framesSinceJumpAtApex > hangFrames)
// Move back to Airborne state when starting to go down again or if input isn't held anymore (buffered jump)
if (_framesSinceJumpAtApex > hangFrames || !_isJumpInputPressed)
_playerState.SendEvent("jump_ended");
}
public void HandleSimpleJump(float delta)
@@ -1395,6 +1411,8 @@ public partial class PlayerController : CharacterBody3D
///////////////////////////
public override void _PhysicsProcess(double delta)
{
if (_currentJumpBufferFrames > 0) _currentJumpBufferFrames -= 1;
LookAround(delta);
CameraModifications((float) delta);
HandleStairs((float) delta);