Calculating correct pitch+roll values from sloped sectors

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.

Calculating correct pitch+roll values from sloped sectors

Postby []Dot » Thu Nov 05, 2020 1:40 pm

I'm trying to figure out without any success at all were the chassis of the model aligns properly (preferably without the treads getting sunk inside the slope) at a sloped surface. I vaguely know that some basic form of trigonometry is needed for that however I cannot figure out a proper formula as no matter what changes I try to the pitch calculation it always end up as a mess and the value I get returned doesn't seem to resemble the slopes angle value at all. If I recall correctly something along the lines of inverse tangent (1 / height of 2 front/rear "vertex" points) is all needed to get the angle of a slope, I also used the "floorz" expression and a ACS call to retrieve that value, however in practice this is not the case. When I drive the vehicle to my test slopes then the chassis angle is totally incorrect and when its close to a edge it looks like it is about to fall down which shouldn't happen.
I looked at other threads if there is any solution to my problem and the closet I have found is this: viewtopic.php?f=123&t=65616 however the link to Blades of Agony codebase license is not clear the last time I have checked, so I didn't bothered to look further unto it at the moment.
Current code:
https://pastebin.com/05hzi0q2 (commontank.zs)
https://pastebin.com/2wTbQ8Cc (MTFunction.acs)
Result:
Spoiler:
Last edited by []Dot on Tue Nov 24, 2020 12:43 pm, edited 1 time in total.
User avatar
[]Dot
 
Joined: 05 Nov 2020

Re: Calculating correct pitch+roll values from sloped sector

Postby []Dot » Tue Nov 24, 2020 12:31 pm

I looked again at the Blades of Agony script and it seems like it has a license now which I understand it seems to be MIT/BSD like license so if I get it right I can use it for my mod, however I have another serious issue with this code, from the looks like it is visual only but as it is right now I cannot use it as it is because when the player is near a sector it has holes there then the tank is heavily pitched down and when its near the edge it looks like it is about to fall down. My understanding of this BoA tank script is very poor and I cannot figure out how to fix this, changing the player collision radius is a absolute no go as it would break map compatibility, trying to change the custom variable "TestLength" does nothing to remedy this issue and I don't know of any flags that makes this visual bug less blatant.

Before using the BoA code it took me 2 weeks trying to roll my own solution, adapting Brutal Doom tank code solution and for this BoA tank code it took me over 1 week trying to adapt it and fixing the new issue it has and so far none of my solution worked, my first attempt of adapting the BoA code was trying to cherry pick the relevant functions which resulted in not working at all and the second attempt was taking all of the code and adding my relevant code to it, it "technically" works now as it is weren't it for this visual bug it has now.

So is it even possible at all to have a pitch function that works in way where it kicks in only when the player/object is in a sloped sector? Because it would be nice when I can use the same code for my custom enemy class which features several different tank types.
Code: https://pastebin.com/Andt2Ckp
Spoiler:
User avatar
[]Dot
 
Joined: 05 Nov 2020


Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests