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 / moving in a 3d world

Author
Message
Stevie
User Banned
Posted: 6th Jul 2004 01:46
Within the game environment in most games u have the character that u move to a certain degree and then when the character gets to a certain point - the world moves. How do u achieve this??????
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 6th Jul 2004 03:10
That is done most often by placing limits how far the character can move while on the screen, say within 100-200 pixels of the screen center. When the limit is reached, you scroll the background map. (That's the 2D explanation.) For 3D, you'd do much the same thing but do a distance check on your camera from the character, making the same scroll effect if the character reaches X distance away. And for 3D, you don't move the map so much as you move the camera, because moving the world would slow down things a lot.

Any truly great code should be indisguishable from magic.
Zeal
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: Colorado Springs, CO
Posted: 6th Jul 2004 03:25
Heres how I like to explain it...

Imagine your terrain as a bunch of bathroom tiles sitting on the floor. Arrange them all into one big square grid. Now place the player/camera in the center of the grid (the center bathroom tile). Keep track of what grid/bathrrom tile the player is in at all times as he moves around the terrain (simple division of position by tile size).

Now, lets say the player moves 'up' to the tile right above him. All you have to do is pick up the bottom row of tiles and place them along the top row. Reshape them all (this can be a little tricky, read up on vertex manipulation), and bingo, you have unlimited gamespace.

Use the same logic to load in objects (like trees, rocks, ect...). When you cross from one sector to another, delete all the old objects in the 'back' row, and create the new objects in the 'front' row. Build a loading/deleting queue to make this proccess nice and smooth.

All you need is zeal

Login to post a reply

Server time is: 2024-09-22 15:33:45
Your offset time is: 2024-09-22 15:33:45