Agustin,
Gravity of some sort is needed, but let's talk about how we implement that...

What is desired? To hold the cylinder _down_ on the terrain of movement. Therefore I'd 
suggest that you periodically (every exitFrame, prepareFrame or using a timeout 
object) determine the model's position in the plane of movement (you cite "y" as up, 
therefore the plane of movement is the x-z plane), then from the model's position cast 
a ray downward (along -y in your case). This ray will intersect the terrain below and 
the detailed information returned will allow you to get the distance between the model 
and the point of intersection. If this distance is less than desired, calculate the 
diff and raise the model (increase its y position by that diff amount). If this 
distance is greater than desired, calculate the diff and lower the model (decrease its 
y position by that diff amount).

Does that help? I'm using this same technique in my terrain following demos for the 
dummy box used to orient the biped character, but with a twist. I was concerned with 
the character possibly moving so far between ray casting that it might actually drop 
below my terrain (and thus a ray cast downward would *never* intersect the terrain). 
Therefore I actually cast a ray from a point at some increased altitude position 
directly above the model (I pick an altitude higher than my highest mountain top for 
example). This prevents any problems if the character drops below the terrain. This 
may or may not work for you being as you'll have a second floor somewhere above your 
head leading to confusion.

I hope my thoughts have helped, keep us posted on how things go!

Rock on,
Tom

> -----Original Message-----
> From: Agust�n Mar�a Rodr�guez [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 28, 2001 3:50 PM
> To: [EMAIL PROTECTED]
> Subject: <lingo-l> 3D Follow Terrain �do I need gravity?
> 
> 
> Thanks Tom Higgins and Alex Smith for your help. It has been 
> very useful
> to me.
> 
> I would like to know how my cylinder (happy parent of my camera) can
> follow a simply terrain. For example: to walk on a stair and 
> going from
> the first floor to the second. Let�s do it without steps, 
> only climbing
> a ramp.
> 
> I imagine that I can tell the cylinder to increase the Y axis when it
> collides with the ramp. Suposing that�s right, for going down I would
> have to put an invisible ramp in the roof and decrease the Y axis?.
> 
> These ideas are a little bit crazy, so I imagine that it has 
> to be some
> gravity behaviour for going down like there is in the common 2D
> sprites.  I�ve tried to figure this out alone studing the 
> terrain follow
> and Island examples, but they are too difficult to me and I 
> don�t think
> my simple stairs require all that code.
> 
> I would aprreciate your help. Thanks again.
> 
> 
> [To remove yourself from this list, or to change to digest mode, go to
> http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
> email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
> Lingo-L is for learning and helping with programming Lingo.  Thanks!]
> 

[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to