Welcome Guest [Log In] [Register]
We hope you enjoy your visit.


You're currently viewing the Ultimate 3D Community as a guest. This means that you can only read posts, but can not create posts or topics by yourself. To be able to post you need to register. Then you can participate in the community active and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.

Join our community!

If you are already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Sit Flush on Terrain.
Topic Started: Dec 1 2007, 09:38 AM (207 Views)
Zedman3d
Member Avatar
Forum God
[ *  *  *  *  *  * ]
How do i make an object sit on the terrain but slope with it too. I did get the code to make it sit on the terrain but i want the slope code. I think i need to use trig but dont know the functions needed....

Thank you. ^_^
Quote:
 
Eanbro: My problem with C++ is that not everything is included to start making projects with it.
Quote:
 
Dr.B: Your problem with C++ is that you want it to be like Game Maker...
Offline Profile Quote Post Goto Top
 
$pecter
Member Avatar
Elite Member
[ *  *  *  * ]
I don't know about setting the rotation variables in U3D but I do know about trig. :)
I would do this by finding the height of the terrain in front of the object and determining to slope from that.
Posted Image
The tangent(tan) of the angle theta(θ) is equal to change in z(δy) change in x(δx)
So in gamemaker
Code:
 

dy=abs(z-get_terrain_height);
dx=2;//this is how far ahead you want to check
theta=arctan(degtorad(dy/dx));


EDIT: Sorry, I used delta y when it should have been delta z :doh:
Offline Profile Quote Post Goto Top
 
« Previous Topic · Questions about Ultimate 3D · Next Topic »
Add Reply