Sign in to follow this  
vexe

In-game trigger boxes?

Recommended Posts

Greetings,

we're making a 90s style game with prerendered backgrounds and static camera angles using a custom software-based engine (Sample WIP video)

I was wondering what's the best way to go about setting up camera triggers. In the video I was manually switching cameras. I was thinking just OBBs (or AABBs), every camera would be associated with a bounding box, if you're in box A then camera A renders.

- Is this a good approach or is there a better more simpler/automated way of doing it? How did old games like Resident Evil or Final Fantasy do it?

- Doing it this way I'd have to use some sort of editor to setup the boxes. We're using Blender so I guess I could use that, although I'd prefer a more specialized editor. Is there any good 3rd party editor that's more suitable to doing this stuff? (The same editor would be used for door triggers, item/enemy spawns, text triggers etc). I thought about writing my own editor but that's a bit luxurious at the moment, I'm still setting the core things up.

Any ideas/help is greatly appreciated
Thanks
-vexe

Edited by vexe

Share this post


Link to post
Share on other sites

Bounding boxes seem reasonable to me. I wouldn't try and automate the process though, since this style of game relies pretty heavily on deliberate placement and selection of the camera at any given time. Since it's just a box, I don't see any reason not to just use Blender to place them. I'm not familiar with that tool in particular, so I can't comment on how you'd tag the boxes with additional information so the engine knows they're camera triggers (so they shouldn't be rendered). But I assume something like that is possible...

One thing you want to watch out for however are the effects of hysteresis. In this case, that would occur if the player is right on the border of two adjacent camera boundaries and moves slightly back and forth across the boundary, causing the camera to jump back and forth in a jarring and jittery fashion. To get around this, you would make your bounding boxes overlap by a certain amount, and only change the camera when the player leaves a bounding box, as opposed to just when they enter a bounding box. This creates a spatial buffer where the current camera "sticks" a little longer.

Share this post


Link to post
Share on other sites

Thanks for the reply @Zipster. Blender does seem the most reasonable approach. So I went ahead last night and just did it. Here's a clip for cameras, and here's text triggers. I haven't ran into the issue you mentioned yet, I will keep an eye on it, thanks for the headsup! For now I'm just doing a simple Point in AABB test to see which box I'm in and render the camera that's associated with that. I guess I'll try and make hysteresis happen. Never knew this thing has an actual term, cool.

To answer your question, the way the boxes are associated with their cameras is just by naming. In Blender, I name my cameras Camera_1, Camera_2 etc. So the boxes would be Box_C_1, Box_C_2 etc. As you see in the video there could be an instance where you need multiple boxes to cover a shot, and for that you get Box_C_3_0 and Box_C_3_1, it's pretty lame that Blender doesn't let you name two objects the same so I had to use another postfix.

The way I import things is via Assimp. I save .blend directly, preprocess it to an internal engine format and use that. I will write a file watcher of some sort to keep an eye out on the input files, as soon as it detects a change it will invoke the preprocessor and reload the .blend on the fly making edits more practical cause you could just Ctrl+S from Blender and see the change take affect.

Share this post


Link to post
Share on other sites
23 hours ago, vexe said:

We're using Blender so I guess I could use that, although I'd prefer a more specialized editor.

Thanks for this, I needed it.:D

You are overthinking this, like wanting to know if there is special paper made for drawing squares on.

Bounding boxes is 3D cubes, you could pay for expensive 3D software and get the exact same cube Blender will give you.

Blender is even better that most software for this kind of thing, because it has python. If you need tags or any special data to attach to boxes you can build your own exporter that does this for you.

A bounding box is just 4 points, 3D tools gives you a visual aid in moving them around.

 

It's also not worth building your own in-depth collision editor for these, instead make one where you can move colliders around for compound collisions. Use your 3D tool with a custom prefix to check if it's a collider or not.

1 hour ago, vexe said:

Box_C_3_0 and Box_C_3_1, it's pretty lame that Blender doesn't let you name two objects the same so I had to use another postfix.

This is done to keep things neat, it is maybe a pain with this one setup yet you will be thankful when it comes to rendering and composition.

Once you have imported the object you are free to remove tags so you can name a camera: Box_C_3_0 and Box_C_3_1 and tell your importer to delete the last two characters from the name.

With the names you have here you could end up regretting them. I advice giving each camera a name that tells you what it does. For example you can name one "CameraFacingFrontDoor" so that you know what each does.

23 hours ago, vexe said:

- Is this a good approach or is there a better more simpler/automated way of doing it? How did old games like Resident Evil or Final Fantasy do it?

Many games used a approach like you are doing now or even 2D colliders and screen space checks. Remember the tools you have now is a hundred times better than what they had to work with back then.

I wonder what Resident Evil would have looked like if they could have used Blender with cycles for rendering.

 

Share this post


Link to post
Share on other sites

@Scouting Ninja Glad I gave you something you needed :D

I just meant some sort of quad view editor like they had for Doom or Quake (example). I just love wireframe/ortho diagrams in quad views, nerdy stuff, it looks so retro. I was able to get quad views in Blender though.

For collision we're using a simplified level mesh for static collision geometry, and an ellipse for the player/enemies. For items/pickups etc, could just be a sphere or box. I'm thinking of using Blender for all of those too.

Custom exporter, yes eventually. Also a way to automate work for my artist having to go through each camera in the scene to spit out a color and depth map. I just never enjoyed working with Blender API in Python.

Good point on the names, I forgot I could just change them in the preprocessor. This is why you discuss things with people!

I don't think "CameraFacingFrontDoor" is a good idea in my case because, cameras don't do anything special, they're just a position/rotation in space with a FOV to render things from. And, "FacingFrontDoor" means you have to have some sort of predefined actions some where that those names could follow. Now you have to parse more stuff and compare it to your symbols to get a match. I'd much rather have a level meta file that has that extra information in it instead of baking it in the name. With the Camera_N convention, N is just an id that you could associate things to easily. Less parsing too, just a number. You read that id and index into some camera data structure that maybe has FacingFrontDoor=true, ShakeAndBakeIntensity=3.14 and etc=false

Share this post


Link to post
Share on other sites
46 minutes ago, vexe said:

Custom exporter, yes eventually. Also a way to automate work for my artist having to go through each camera in the scene to spit out a color and depth map.

Because blender is a rendering software there is many ways to do this without code.

The best way to do it would be with markers: https://blender.stackexchange.com/questions/3502/how-can-i-make-a-camera-the-active-one

Once you have that set you can use the composer to rip depth passes. Because depth will change based on range you can animated the offset value in your mapper.

Note: Blender needs the AnimAll addon enabled to animate values. It is installed with blender just go to addons and turn it on.

 

Attached is a Blend file I made for you, it will render the color to the temp folder and a depth folder will also be there.

Hope it helps.:)

 

The worst way to do it would be with drivers and code is in between the two.

 

Blender is 5-6th rated 3D software in the world and it's lower score is because of usability. There is noting it can't do, you just need to find how.

 

BlenderCameraHelp.blend

Edited by Scouting Ninja

Share this post


Link to post
Share on other sites
Quote

Attached is a Blend file I made for you, it will render the color to the temp folder and a depth folder will also be there.

Aww dude thanks greatly appreciated. That's neat! Will show it to my artist

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this