Align actor to sloped floor

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
Cherno
Posts: 1311
Joined: Tue Dec 06, 2016 11:25 am

Align actor to sloped floor

Post by Cherno »

I have an idea in my head that involves using model actors for vehicles like tanks, and a 3d landscape with uneven ground, so lots of slopes.

Of course, the vehicles should align themselves to the floor, has anyone ever attempted something like this?

My idea would be to use A_SetPitch and A_SetRoll with an angle that is computed by using GetZAt at two points, one at the front and one at the back of the vehicle.
User avatar
RiboNucleic Asshat
Posts: 501
Joined: Thu May 09, 2013 8:15 pm
Preferred Pronouns: No Preference
Graphics Processor: nVidia with Vulkan support
Location: Exactly where I am
Contact:

Re: Align actor to sloped floor

Post by RiboNucleic Asshat »

I believe Nashgore: Vengeance Edition contains code for aligning an actor to the slope of a plane. You can find the relevant code in NashGoreStatics.zc:
Spoiler:
You could study this and adapt it to your needs. Possibly ask ZZYZX about it too.
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Align actor to sloped floor

Post by Nash »

Do note that that is useless for vehicles because its sample point is the middle of the actor. For vehicles, you need at least 4 sample points (one at each wheel).
User avatar
Cherno
Posts: 1311
Joined: Tue Dec 06, 2016 11:25 am

Re: Align actor to sloped floor

Post by Cherno »

Thanks for the tip. Now I have to figure out the math :?
Post Reply

Return to “Scripting”