Page 1 of 1

Dynamic PlayerPawn properties?

Posted: Fri Mar 15, 2019 6:24 pm
by lumbo7332
I'm looking to be able to dynamically adjust the player's view height based on whether they are aiming down the sights of a rifle or not. Is this possible?

Re: Dynamic PlayerPawn properties?

Posted: Fri Mar 15, 2019 11:57 pm
by Matt
You can change the viewheight property on the playerpawn, but I haven't checked how exactly it would interact with crouching.

EDIT: you may need to multiply the height by player.crouchfactor or something similar.

Re: Dynamic PlayerPawn properties?

Posted: Sat Mar 16, 2019 10:13 am
by lumbo7332
Matt wrote:You can change the viewheight property on the playerpawn, but I haven't checked how exactly it would interact with crouching.

EDIT: you may need to multiply the height by player.crouchfactor or something similar.
Can you do it dynamically based of in-game input?

Re: Dynamic PlayerPawn properties?

Posted: Sat Mar 16, 2019 11:50 am
by Matt
Try putting in your playerpawn's Tick() somewhere and give it a try:

Code: Select all

if(player.cmd.buttons&BT_ZOOM)player.viewheight=viewheight*0.8*player.crouchfactor;
else player.viewheight=viewheight*player.crouchfactor; 
A correction to my previous post: best to only manipulate "player.viewheight" (a property of the player thinker) not "viewheight" (a property of the player pawn) since that's the way it's done in the crouching code.