Jump to content

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

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.

Edited by SaladBadger

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...