Skip to content

Commit

Permalink
Disallow jumping while forcefully crouching
Browse files Browse the repository at this point in the history
  • Loading branch information
gecko0307 committed Jan 15, 2025
1 parent 6a52171 commit 858c12e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Dagon 0.19.0 - TBD
- New package `dagon.collision` - basic collision detection system
- **Extensions**
- `dagon:newton`:
- `NewtonCharacterComponent` improvements
- `NewtonCharacterComponent` improvements: new method `crouch` and better ground check. The origin of the character is now its feet point instead of the barycenter
- `NewtonRigidBody.sensorCallback`, `NewtonRigidBody.contactCallback`
- `dagon:ftfont`:
- Rename the Windows library to `freetype-6.dll`.
Expand Down
12 changes: 6 additions & 6 deletions extensions/newton/src/dagon/ext/newton/character.d
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class NewtonCharacterComponent: EntityComponent, NewtonRaycaster
bool isJumping = false;
bool isFalling = false;
bool isCrouching = false;
bool forcefullyCrouching = false;
bool isForcefullyCrouching = false;

Vector3f groundPosition = Vector3f(0.0f, 0.0f, 0.0f);
Vector3f groundContactPosition = Vector3f(0.0f, 0.0f, 0.0f);
Expand Down Expand Up @@ -224,19 +224,19 @@ class NewtonCharacterComponent: EntityComponent, NewtonRaycaster

if (shouldCrouch)
{
if (!isCrouching && !forcefullyCrouching)
if (!isCrouching && !isForcefullyCrouching)
{
forcefullyCrouching = true;
isForcefullyCrouching = true;
NewtonBodySetCollision(rbody.newtonBody, lowerShape.newtonCollision);
}

targetEyeHeight = minEyeHeight;
}
else
{
if (!isCrouching && forcefullyCrouching)
if (!isCrouching && isForcefullyCrouching)
{
forcefullyCrouching = false;
isForcefullyCrouching = false;
NewtonBodySetCollision(rbody.newtonBody, shape.newtonCollision);
targetEyeHeight = maxEyeHeight;
}
Expand All @@ -252,7 +252,7 @@ class NewtonCharacterComponent: EntityComponent, NewtonRaycaster

void jump(float height)
{
if (onGround)
if (onGround && !isCrouching && !isForcefullyCrouching)
{
onGround = false;
float jumpSpeed = sqrt(2.0f * height * -rbody.gravity.y);
Expand Down

0 comments on commit 858c12e

Please sign in to comment.