Dynamic PlayerPawn properties?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

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.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
lumbo7332
Posts: 36
Joined: Fri Jul 27, 2018 10:21 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Fedora Kinoite
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Dynamic PlayerPawn properties?

Post 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?
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: Dynamic PlayerPawn properties?

Post 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.
User avatar
lumbo7332
Posts: 36
Joined: Fri Jul 27, 2018 10:21 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Fedora Kinoite
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Re: Dynamic PlayerPawn properties?

Post 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?
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: Dynamic PlayerPawn properties?

Post 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.
Post Reply

Return to “Scripting”