Scripts / Align entity with terrain slope

Author
Message
Gtox
3D Media Maker
9
Years of Service
User Offline
Joined: 5th Jun 2014
Location: South Africa
Posted: 8th Oct 2018 06:52
Is there a relatively simple way to align an entity with the terrain slope? With bipeds it doesn't matter, but with quadrupeds it looks weird when they move up and down slopes .
i3 8350k 3GB GTX1060 8GB RAM Windows 10
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 8th Oct 2018 19:17 Edited at: 8th Oct 2018 19:19
Use GetTerrainHeight to find the y value under the legs (assuming you know where the feet are, you'd have to work that bit out first) then when you have all four values work out the angle you would need to sit square with the terrain and use SetRotation to rotate the entity to that angle.

If you look for my truck demo thingy all the code you would need is in there.

But 'relatively simple'? No.

Edited to add: If it is an animated entity then you may have trouble working out where the feet are!
Been there, done that, got all the T-Shirts!
PM
Gtox
3D Media Maker
9
Years of Service
User Offline
Joined: 5th Jun 2014
Location: South Africa
Posted: 9th Oct 2018 04:34
Thanks AmenMoses, I'll have a look at your truck demo.
i3 8350k 3GB GTX1060 8GB RAM Windows 10

Login to post a reply

Server time is: 2024-05-08 16:20:36
Your offset time is: 2024-05-08 16:20:36