Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411423 Posts in 69363 Topics- by 58416 Members - Latest Member: JamesAGreen

April 18, 2024, 10:03:37 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Loading and unloading level geometry
Pages: [1]
Print
Author Topic: Loading and unloading level geometry  (Read 1302 times)
RoboDusty
Level 0
*



View Profile
« on: June 10, 2020, 12:16:17 PM »

So I recently got back into GameDev stuff, and I'm working on a 3D FPS in Game Maker Studio 2. I know many people will probably be of the opinion that I should just use Unity or Unreal, but at least with respect to Unity: I've tried it and it never clicked with me for some reason.

That being said, on to the topic.

https://twitter.com/RuinsOfDust/status/1270601235406581761
(Is there a better way to link tweets?)

Here's where I'm at right now. It 'works' from a functional standpoint, but it has it's holes, sometimes literally.
I have a nagging feeling that I'm doing something fundementally wrong, so let me explain the process:

The initial data is pulled from a text-file, a "Level" object is created, and objects/geometry are placed accordingly and are assigned to the Level object. Once all this is done, the geometry is asked to add the relevant triangles to the Level's vertex buffer, which the Level then freezes, and renders. While the geometry is adding to the buffer, it's also pushing the bounds of the Level out.

Upon opening a transition door, this whole process gets repeated for the new "Level". However, before the geometry is asked to add it's terrain to the buffer the door that links the two rooms together is found and set as an anchor point. All the objects and geometry are then shifted and rotated appropriately so they end up in the proper position.

A couple of other notes:
  • The Levels have a ticking decay timer that counts up whenever the player's coordinates are not inside of the bounds of the Level. Once it hits 3 seconds, the Level is deleted, the buffers are freed, children are destroyed, and it's like the Level never existed. This doesn't happen if there's only one Level instance left
  • The bounding boxes do not rotate with the Level, and if a Level were to completely envelop another Level (Like say, a donut shaped room with a smaller room at the center), the outer Level would never decay
  • Doors are for the most part side-agnostic. They don't know which side you're accessing it from. They know which Level they lead from, and where they go to. This is probably a spot that could improve.
  • Doors at the moment overlap. This causes the "spinning" animation on the door. That's not spinning, that's z-fighting.
  • The player object doesn't actually know which level it's in. Again, a spot that might be improved.

This all leads to a couple of problems:
  • I'm uncertain how to proceed with a map function.
  • Due to the agnostic nature and the bounding boxes, it's rarely possible for you to be on the wrong side of the door, meaning the room you're "in" despawns.
  • I'm not sure how I'd go about spawning in all adjacent rooms with the current system. Something about interacting with all the doors in my current Level, then spawning the Levels appropriately. However, keeping them from decaying seems harder.

I'm pretty willing to scrap the whole system as I've written it and make a new one if there are any suggestions!
My only real requirements are that it's a seamless movement, much like Metroid Prime, and that I can keep my level building code. Though that second one is negotiable, if the alternative is right.
Logged
BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #1 on: June 14, 2020, 12:32:39 AM »

Quote
I'm uncertain how to proceed with a map function.
This can be done identically to the levels themselves, loading and unloading chunks, but it's probably easier just to pregenerate a map that covers all levels.


Quote
I'm not sure how I'd go about spawning in all adjacent rooms with the current system. Something about interacting with all the doors in my current Level, then spawning the Levels appropriately. However, keeping them from decaying seems harder.
A room should only decay if the player is not in its bounding box, or the bounding box of any adjacent level.

Or alternatively, you can just increase the size of the bounding box of each level, and similarly have a large box around each door that triggers pre-loading the level.
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic