Prevention of Intersection

Blitz3D Forums/Blitz3D Programming/Prevention of Intersection

ClayPigeon(Posted 2010) [#1]
I'm working on an FPS in which the current level can be changed during gameplay. When the level is changed, nothing changes except the level mesh, and the player's position stays the same. If there is something inside the player in the second level that's not in the first (e.g. the ground is higher) the player will no longer be on the ground and plummet to their doom. I need some way to be able to prevent this whether it's to bump the player away from the obstacle upon switching levels, or checking for a collision and not allowing the player to even switch if there is. This is a hard problem to solve. I might even have to go to the extreme of having to replace the character at the beginning of the level each time, which I am very reluctant to do. Any ideas??


Whats My Face(Posted 2010) [#2]
I would try placing pivots evenly at safe areas throughout the levels. Then when a new level is loaded just quickly check which pivot the player is closest to and then you don't have to worry about the ground being higher because he'll just be moved to the nearest workable location. By the way, why would you want to start a player half way through a level?


Shambler(Posted 2010) [#3]
Do a linepick from a very high position to a very low one through the players position ( to cope with any possible terrain height ).

Once you know the height of the terrain in the next level you can reposition the player.

If the player collides with something in the new level I would move them away from it or teleport them nearby.


ClayPigeon(Posted 2010) [#4]
@Whats My Face: It's a sort of time travel thing - there are separate versions for different times. Don't you think it would get a little tedious placing all those pivots?

@Shambler: What if the player's in a tunnel or a building? Also I'm not sure how Blitz detects collisions, but I do know that when the player is intersecting with something, it doesn't return a single collision. That I found to be a little strange..


MusicianKool(Posted 2010) [#5]
you could load all the meshes at ounce, and hide all but the one your on, create a pivot that traverses each mesh with the player, then when you need to switch meshes, just position the player and camera to that mesh and un-hide it and hide the original.

or make each mesh with the same starting vertex point and dimensions so that when you load the other mesh the player ends up in the same spot just in a different mesh.


ClayPigeon(Posted 2010) [#6]
Wait, are you saying create separate pivots that are affected by all of the meshes, or.. what? I'm not sure I understand what you're saying.


Whats My Face(Posted 2010) [#7]
OK, how 'bout this? Kind of like what I think MusicianKool said, you place all the levels on the same x,z plane but offset the y. Create a pivot for each level. When the player presses a button move all the pivots accordingly, or if there is a lot of platforming involved just make the pivot try and go to the position where the pivot you are currently working with is. Collisions will prevent the non-active pivots from going outside the level. When you want to change a level just move the player to the correct pivot.


ClayPigeon(Posted 2010) [#8]
I see. That's a good idea. But, if I was having the pivots go to the player's position relative to their own level, couldn't they get stuck in a corner or something?


_PJ_(Posted 2010) [#9]
I think the suggestion was to use pivots to place the Player at the right heiight or away from any other objects.

If you know the levvel meshes, and where objects are placed, then there asshouldn't be a need for this as the level mesh itself would be placed at the right place and spawned objects in a new level should not be placed at the player's position.

Might be best to work from this angle instead, and arrange the position of the new level and spawned entities with respect to the player position rather than the other way round...


Drak(Posted 2010) [#10]
Why not simplify the process and only have the time change possible at certain locations? That way you can make sure the different levels won't interfere with the character at those locations.


ClayPigeon(Posted 2010) [#11]
@Malice: I don't think you realize how my game works. I'm having the player travel to another version of the level (in the past or future) and where the player is might have something that wasn't there in the past (such as a hill or a building). I'll make sure that there's nothing colliding where the player starts in each level, though.

@Drak: I thought about that, but Blitz's collisions use polygons, and if the player is completely and fully inside the obstacle, with no polygons colliding it will return no collision. Unless you're saying to set specific locations where the player can time travel. That might work, but that would take forever to place all the pivots for the locations, and might confuse the player when they can't time travel for no apparent reason.


Warner(Posted 2010) [#12]
First, would they need to be actual pivots? Maybe a database with positions would be sufficient. And maybe this list/these pivots can be automatically generated by a separate parsing program?
Second, perhaps don't disallow any invalid transitions, but transite to a nearby valid location instead.
I was thinking of this (2d) game, also something with time travel, but solved in a different way:
http://www.kongregate.com/games/rujo/james-replay-egp-edition


ClayPigeon(Posted 2010) [#13]
That sounds like a plausible solution. I'd like to try it, but I don't have the program with me right now. I'll let you know if it works!