Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
ArrivedHero

Crouching: What exactly is going on?

Recommended Posts

What exactly is the engine doing when the player chooses to crouch? I poured through ZScript in "shared" for anything and the closest I could find what I am looking for were a couple of internal functions that handling crouch movement but none of them really explained how the sprites change or the player's height. Also, is there a button for toggle crouch? I don't mean the option to toggle but like an actual "BT_TOGGLECROUCH". Because currently I'm working on a ZScript that will switch the player's camera from their own to a child tracer, and I can only get it to work by using the hold down method.

 

Does the engine morph the player and retain all their items and stats or something when they crouch?

Share this post


Link to post
Posted (edited)

No, there's no morph. I don't remember if this is recent or not, but the vast majority of the crouch code is scripted at this point.

 

Gist of it I can determine:

Tick(), as part of its usual thinking for the player, overrides the player Height property. crouchfactor is a measure of how "crouched" the player is at the moment.

CrouchMove(int direction) is responsible for making you more or less crouched, and it is what regulates uncrouching when you're in a space that's too short to stand up.

CheckCrouch(bool totallyfrozen) actually kicks off crouching, reading the input for it.

 

The sprite changes, on the other hand, appear to be native and aren't set in the script. You'll have to find some way to simulate it I guess.

Share this post


Link to post
4 hours ago, SaladBadger said:

No, there's no morph. I don't remember if this is recent or not, but the vast majority of the crouch code is scripted at this point.

 

Gist of it I can determine:

Tick(), as part of its usual thinking for the player, overrides the player Height property. crouchfactor is a measure of how "crouched" the player is at the moment.

CrouchMove(int direction) is responsible for making you more or less crouched, and it is what regulates uncrouching when you're in a space that's too short to stand up.

CheckCrouch(bool totallyfrozen) actually kicks off crouching, reading the input for it.

 

The sprite changes, on the other hand, appear to be native and aren't set in the script. You'll have to find some way to simulate it I guess.

I appreciate the help, but this does seem like something that I am going to have to simulate through a "crouch" state or morph, I will continue looking through this. Thank you.

Share this post


Link to post

Ok, figured it out, it is in CheckCrouch(). The if else statement that has the CrouchMove() function is where I want to place my code. Thanks again.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×