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 / array code request

Author
Message
David iz cool
19
Years of Service
User Offline
Joined: 21st Sep 2005
Location: somewhere lol :P
Posted: 15th Jul 2009 23:01
hi i wanted to ask if someone could give me some code to do this?

i want to load my world,trees rocks etc everything then have an array record all positions.then have the array load that object only if my player is within like 500 distance from it.otherwise it is deleted.
i dont know much about arrays.im trying to make a huge world like morrowwind or oblivion but i dont know how to code loading the objects. i dont want to just hide the objects because i think the game will be slower. can someone help?
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 15th Jul 2009 23:38
Actually hiding objects is far quicker than loading them.

There are plenty of examples of this on the board - try searching for LOD (level of detail) and you should run into several code snippets dealing with this kind of problem.

"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 16th Jul 2009 00:52 Edited at: 16th Jul 2009 01:15
Here's an outline of how I would go about doing it. There's probably lots of ways to make this faster, but here's how I would do it anyway:



If you ran that code every loop (or every few loops for even more speed) you would hide all objects that are far away. I use EXCLUDE OBJECT ON/OFF instead of HIDE/SHOW object because hide object doesn't actually improve speed. Even though the object is invisible, its polys still appear in the poly count (I think, anyway. Exclude object ON/OFF is faster though.)

That code won't actually run. You would have to adapt it to your game, but hopefully it will point you in the right direction. Good luck


EDIT: Whoops! I thought you already had the array made. Try reading some tutorials on arrays, then coming back to this concept.

EDIT2: Alright here's a simple example that doesn't use User Defined Types:



And an example with User Defined Types:


The space changes in the distance calculation are just to make things easier to read.

<-- Spell based team dueling game!

Login to post a reply

Server time is: 2024-11-25 04:57:36
Your offset time is: 2024-11-25 04:57:36