Door to new level

Posted By: 3run

Door to new level - 02/07/11 16:10

Hi, I need someone to help me with a little problem that I've faced (with code snippet or with an advice how to make this). I have a door in the middle of the room, so all I want is, after opening this door (I use animation for that) I want to see in the doorway next level (and player must be able to see it only from one side of the door). I know that I can use an other view on entity, but how to show there a new level? And how to make player move to that level? BTW moving to the next level must be similar to portals in PORTAL, I mean they must be smooth, and player must be able to walk back as well (this is unpaid, but credit may be possible).
Posted By: Pappenheimer

Re: Door to new level - 02/07/11 17:36

You can't switch between levels this way, because when loading a level, the current level will be closed and all entities within will be removed.
That's principle of levels in Acknex.
Quote:
# The current level is closed, the cache holding level entity files is purged. All current entities in the old level are removed, thus all entity pointers referring to them can't be used anymore. For preventing an entity file from being purged at level change - which could make sense for speeding up level loading - define it as a view entity.

http://www.conitec.net/beta/alevel_load.htm
Posted By: 3run

Re: Door to new level - 02/07/11 18:04

Thank you. I have an idea how to make it another way:
I'll make two rooms (in one level), each of rooms has a door, how can I move from one room into another an back via doors (smoothly so I could be even able to stop right in the middle of the doorway and turn around, move etc (as in portals in Portal game))? I know that I can use views to see the next room in the doorway. But I have no idea how to handle smooth moving between levels?
Posted By: painkiller

Re: Door to new level - 02/07/11 18:13

maybe add a passage common to the two levels, and do the level change when you are in the passage
Posted By: Rei_Ayanami

Re: Door to new level - 02/07/11 18:18

You could create your levels normally, and than put all the wmb files into one big level. From there you make that level parts invisible/visible.

But I do not know how fast that will be.
Posted By: 3run

Re: Door to new level - 02/07/11 18:33

Each of level is going to be a room, so I'll just put them into one level (all of the rooms). So I have an idea how to handle levels. But I have no idea how to make smooth movement between levels...
Posted By: Redeemer

Re: Door to new level - 02/07/11 23:05

The developers of Half-Life accomplished this by putting an invisible marker in both levels that acted as common reference points between the two levels. They then made an exit area in both levels that looked identical between them, and put some "change level" triggers in that area (the triggers can be in different places in each level). Then whenever the player touched the trigger, the game would load the new map and set the player's location in the new map to the same relative place as the old map, using the markers mentioned before as common reference points between the two levels. The result was a seamless transition between the two levels.

If you don't understand what I'm saying I can create some pictures that explains the whole process in simple terms.
Posted By: 3run

Re: Door to new level - 02/07/11 23:55

I got the main point with triggers, but I'll be very grateful if you make some pictures.
Posted By: wdlmaster

Re: Door to new level - 02/08/11 13:06


The red circles show the "transition area" both levels must have in common. The small red lines are the actual triggers. If you touch a trigger, you must:
1) calculate the distance to the trigger
2) load the next level
3) add the distance to the start position of the next level
If you don't add the distance to the level's start position, you always start the new level at the exact same position no matter where you touched the trigger in the previous level.

The yellow dots are the start positions of the next level. Within the transition area, the relative trigger position of the current level MUST be equal to the relative start position of the next level (their real coordinates can be different)
Posted By: 3run

Re: Door to new level - 02/08/11 13:21

Thank you. I have few questions:
*Will this make movement smooth? Cause if I got you right, the method you showed me, will just place player at the new level, with distance from door from old level's door. Am I right?

* how to make this without loading new level, cause I'll make all levels(rooms) in one big level.
I need to be able to move smoothly between door, as I said before. I need to be able even to stop right between doorways.
Posted By: wdlmaster

Re: Door to new level - 02/08/11 13:54

Quote:
Will this make movement smooth?

no, because a completely new level is loaded.
Quote:
Cause if I got you right, the method you showed me, will just place player at the new level, with distance from door from old level's door. Am I right?

yes
Quote:
how to make this without loading new level, cause I'll make all levels(rooms) in one big level.

simply set the player's position to the next start position (and add the distance to it). In that case, the transition is smooth.
Quote:
I need to be able to move smoothly between door, as I said before. I need to be able even to stop right between doorways.
You can always walk everywhere between the triggers. You just have to make sure, that the look of the transition area and the RELATIVE placement of the triggers/start positions are 100% identical. If not, you'll notice the position jump...
Posted By: 3run

Re: Door to new level - 02/08/11 14:19

If I put first door in the middle of the first room and will place second door on the celling of the second room and will turn door downwards, movement will not be smooth?
All I need is something similar to portals in Portal game. So even models needs to move smoothly between doors like this:

Red thing is a model.
Posted By: Quad

Re: Door to new level - 02/08/11 14:52

you need 2 entities and reference points in both rooms, one entity can't be in 2 places at same time, space time continuum etc. heavy sutff.
Posted By: wdlmaster

Re: Door to new level - 02/08/11 14:54

You want to make a portal clone. Well, then the concept from Redeemer and my clarification is totally irrelevant! Because for "portals" you need a completely different approach. If you move objects through portals, you must always sync 2 copies of all the models near the portals. You can't just "jump" to the next exit (you could, but then you have some restrictions). As soon as you move objects near a portal, you must generate a 1:1 copy of the models, because you NEED them to show both portal exits. And you have to deal with way more problems. You must adapt the player function to be compatible with portals: Everything you do in front of one of the exits must be mirrored/replicated on the other side --> so even the player must have another copy of him/herself and you have to transform all movement/rotation between the portals [the list goes on] ...
Posted By: 3run

Re: Door to new level - 02/08/11 15:38

Ohh man...sounds too hard for me, but any way, what if I want to make only player movement through doors (there will be no way for player too see himself in level, so no need to make copy)? I hope that wouldn't be that hard.
Posted By: Redeemer

Re: Door to new level - 02/08/11 17:52

Why not just do it the way I suggested? If it was good enough for half-life, it's probably good enough for you.

I drew some pictures for you that explains the entire process in detail. I just haven't had time to put them up.
Posted By: 3run

Re: Door to new level - 02/08/11 18:04

I'm waiting for you pictures dude laugh
Posted By: Redeemer

Re: Door to new level - 02/09/11 01:17

Ok. Imagine a level like this:


We are looking at this level from a top view. The white lines are the walls in the level. The green dot is the start point. The red lines form the X and Y axis and meet at the origin, a bright red dot. What I want to do is put another level at the end of the hallway to the east.

So, I start making a new level. It includes part of the hallway from the previous level. It isn't in the same spot (relative to the origin point) but it doesn't have to be. In fact, it can be anywhere you want; more on that later.


So, how do we join these two levels together? First, we add a marker between the two levels that is in the same position relative to the hallway. Here's the two levels again, with the markers (represented as purple dots):



Now we add a trigger in the hallway on each of the levels that will move the player between them (represented as blue lines):



Now when the player touches these triggers, first we need to change the level:

Code:
// load the level
level_load(newlevel);


Then, we set the player's position like this:

Code:
// load the level
level_load(newlevel);

// set player's position
player.x = marker_from_new_level.x - ( marker_from_old_level.x - player.x );
player.y = marker_from_new_level.y - ( marker_from_old_level.y - player.y );
player.z = marker_from_new_level.z - ( marker_from_old_level.z - player.z );



That's just untested pseudo-code by the way. I'm not sure it will work as it is.

Some miscellenaneous things to keep in mind when implementing this:

-The markers have to be in the same position relative to the space you want the player to move to, or else when you change levels the player could be anywhere! Look at my examples levels. The purple dots are in the exact same space relative to the wall below them. That's how your levels should look with the markers in place.

-When you switch levels, the old marker entity will be dumped by the engine. You will probably have to retain it's position in a global VECTOR before using level_load:
Code:
// save the marker from the old level
vec_set( saved_vector, marker_from_old_level );

// load the level
level_load(newlevel);

// set player's position
player.x = marker_from_new_level.x - ( saved_vector.x - player.x );
player.y = marker_from_new_level.y - ( saved_vector.y - player.y );
player.z = marker_from_new_level.z - ( saved_vector.z - player.z );



-To create multiple exits in one level, you will have to link each trigger to its own marker. I would suggest that you use handles for this.

-To move other enemies and objects between the levels and create a truly seamless level load like Half-Life, you will have to do more coding that checks the area surrounding the trigger and re-spawns all the old enemies from the last level in their proper places. This will be tricky and possibly memory consuming, since you will have to keep track of all of the objects within all of the levels accessible from the player's current location. For long games you will have to create several points in the game where the player cannot backtrack anymore so that you can offload all of the entity information you have accumulated from the last several levels. Ugh...

Ok... That's about it I think. That was a bit of a brain dump, but it's getting late where I live and I'm tired and I seem to have lost the ability to form long strings of coherent sentences, especially ones that convey complex ideas such as these. Blug.
Posted By: 3run

Re: Door to new level - 02/09/11 08:50

This idea of level changing is clear for me now, thank you for your help bro laugh I appreciate it.
But how to make this in one level? Cause loading new level will stop game for some moment and I don't need that.
As I said before, movement must be smooth, so must looks like door really leads too new place (level or room).
Something like portal, but without coping models, only movement between them. Thank you.
Posted By: mk_1

Re: Door to new level - 02/09/11 11:20

you just can't. At some point the new map must be loaded and since you can't stream a level there will never be a smooth transition.
Posted By: 3run

Re: Door to new level - 02/09/11 13:19

I can't make this movement in one level between two rooms?!
Posted By: mk_1

Re: Door to new level - 02/09/11 13:24

whoops, sorry, you can. IIRC the lag is due to the order of frame execution. In A4 times there was a hint in the manual that you should insert a wait(1); before setting the new coordinates.

Code:
wait(1);
vec_add(player, toOtherRoomVector);


Posted By: 3run

Re: Door to new level - 02/09/11 13:48

So all I need to do is just add new vector to player with wait(1); before adding it?
I can just place player at the new vector too, but will that be smooth? I don't think so... frown
Something about portals:
Gravity with portals
Light throw portals
Some portals
Portal self collusion
This portals made with Newton, but I can't really believe that they create the second copy for a model in second portal...
I don't know, I just can't... For me it's just a hole in that leads to another hole... grin
Posted By: Redeemer

Re: Door to new level - 02/09/11 16:02

Quote:
I can just place player at the new vector too, but will that be smooth?

If you record the player's velocity as you do it, yes. There will be a level_load in between that will cause a slow down, though.
Posted By: 3run

Re: Door to new level - 02/09/11 16:06

Yeah, but I don't need that slow down thing. Thats why I think about having all rooms (or most of them) in one level.
Posted By: Machinery_Frank

Re: Door to new level - 02/10/11 16:00

Why dont you just switch rooms off that cannot be seen? What about the zones feature in A8?
Posted By: 3run

Re: Door to new level - 02/12/11 14:09

Thats exactly how I'm going to put all rooms together in one level, the only problem I'm still facing is smooth movement from one room into other through door... About zone features, I think it's only available for PRO version, or am I wrong? blush
Posted By: 3run

Re: Door to new level - 02/13/11 08:49

Anyone?
© 2024 lite-C Forums