Dynamic PlayerPawn properties?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Dynamic PlayerPawn properties?

Postby lumbo7332 » Fri Mar 15, 2019 7:24 pm

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?
lumbo7332
 
Joined: 27 Jul 2018
Discord: lumbo7332#8067
Twitch ID: pandastic2

Re: Dynamic PlayerPawn properties?

Postby Matt » Sat Mar 16, 2019 12:57 am

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.
User avatar
Matt
Putting the XD into *xdeath since 2007
 
 
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: Dynamic PlayerPawn properties?

Postby lumbo7332 » Sat Mar 16, 2019 11:13 am

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?
lumbo7332
 
Joined: 27 Jul 2018
Discord: lumbo7332#8067
Twitch ID: pandastic2

Re: Dynamic PlayerPawn properties?

Postby Matt » Sat Mar 16, 2019 12:50 pm

Try putting in your playerpawn's Tick() somewhere and give it a try:

Code: Select allExpand view
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.
User avatar
Matt
Putting the XD into *xdeath since 2007
 
 
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia


Return to Scripting

Who is online

Users browsing this forum: Se7eNytes and 2 guests