Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Slight problem with my camera please help...

Author
Message
Cyril Grey
19
Years of Service
User Offline
Joined: 28th Jan 2005
Location:
Posted: 7th Feb 2005 01:54
I have created a matrix with random height of 75. I place a player model in the matrix and set the camera to follow. Occasionally, the model dips beneath the ground and, occasionally, the camera will dip beneath the ground. Can anyone give me a camera to follow snipet that will keep these things from happening? My engine is coming along pretty well with sliding collision, jumping, ducking, projectile firing, camera angeling and panning on the Y-axis so as to see objects above and below the 0 angle fov, etc... But fixing this one problem of slipping below the matrix (however slight) has eluded me.

With math all things are possible
DeHonCha
19
Years of Service
User Offline
Joined: 2nd Dec 2004
Location: A world of my own...
Posted: 8th Feb 2005 05:29
here's how i see it - this is the logic:

check if the camera y is below the matrix height (since it is randomized). if it is keep it from going down - how? store the camera's position at the beginning in a variable like oldcy#. then, if camera position < matrix height, camy#=oldcy#. finally, at the end of the program, position camera camera position x(),camy#,camera position z()

try it out and tell me if it works - if you want the full code you'll have to wait cuz i'm trying it out still - anyway - try it for yourself first - it'll be good experience.

For when they said I couldn't, I did...
Clueless
20
Years of Service
User Offline
Joined: 16th Feb 2004
Location: Corbin, KY, USA
Posted: 8th Feb 2005 09:15
Cyril,

This may not apply to you now, but one thing that bites just about everybody with matrix height sooner or later happens when you reposition your matrix after you create it.

The ground height function returns the height at a point X,Z on the matrix RELATIVE TO WHERE THE MATRIX WAS WHEN YOU CREATED IT. Moving the matrix doesn't change that.

So, for example, if you have a 1000 x 1000 matrix you've molded into a mountain, and the peak is at X,Z (500,500) = 100, then you move the matrix to, say, -1000,0,-1000... the height at X,Z (500,500) is... 100 -- it hasn't changed even though the matrix itself has been moved.

The matrix ground height at X,Z (-500,-500) where you think your mountain peak is now located? Well, it's undefined!

Sorry if you knew this already, but the description of the problem you posted is exactly the symptom of what I'm talking about. I always liked the center of my matrix to be at 0,0, which meant moving it in the negative X,Z directions by 1/2 its X,Z size after creation. Characters or vehicles moving across the matrix would suddenly dip below the matrix 500 units east of the river or canyon in my 1000 x 1000 matrix, even though the ground was flat there...

If you ever move your matrix, adjust the X,Z values you pass to the ground height function by that same offset, and it should work great.

Login to post a reply

Server time is: 2024-11-27 21:29:19
Your offset time is: 2024-11-27 21:29:19