2 registered members (Ayumi, 1 invisible),
584
guests, and 1
spider. |
Key:
Admin,
Global Mod,
Mod
|
|
|
changing the level once my character reaches a certain posiiton
#234379
11/02/08 17:12
11/02/08 17:12
|
Joined: Apr 2004
Posts: 77 USA
Cactus
OP
Junior Member
|
OP
Junior Member
Joined: Apr 2004
Posts: 77
USA
|
K I want my level to change once my character reaches a certain position, or when my player touches a certain object. How should I go about this. I am using the A5 templates. Sorry for being a noob, but help would be great.
HI
|
|
|
Re: changing the level once my character reaches a certain posiiton
[Re: Cactus]
#234410
11/02/08 20:18
11/02/08 20:18
|
Joined: Jul 2002
Posts: 4,436 Germany, Luebeck
Xarthor
Expert
|
Expert
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
|
action LevelChanger_act
{
while(!player) { wait(1); }
my.passable = on;
while(me)
{
if(vec_dist(my.x,player.x) < 50)
{
level_load("level02.wmb");
}
wait(1);
}
}
Other approach using a touch event:
function LevelChanger_event()
{
if(event_type == event_entity || event_type == event_impact)
{
if(you == player)
{
level_load("level2.wmb");
}
}
}
action LevelChanger_act
{
my.enable_entity = on;
my.enable_impact = on;
my.event = LevelChanger_event;
}
Of course you can alter it for using it with multiple levels. Like, define a skill which works as id for the level that is loaded, have a string array (text object) holding all level name strings, and load it using the id as index:
text level_files
{
string = "level1.wmb","level2.wmb"....
}
...
define level_id, skill2;
...
level_load(level_files.string[my.level_id]);
...
hope this helps you a bit
|
|
|
Re: changing the level once my character reaches a certain posiiton
[Re: Xarthor]
#234416
11/02/08 20:56
11/02/08 20:56
|
Joined: Oct 2007
Posts: 5,210 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
|
Xarthor's 2nd approach is good imo, but you should remove the levelchanger entity right after the impact event called because if you dont remove it, impact event wil get called everyframe, means it will call level_load in everyframe of impact which causes engine to freeze.
3333333333
|
|
|
Re: changing the level once my character reaches a certain posiiton
[Re: Xarthor]
#234432
11/02/08 22:29
11/02/08 22:29
|
Joined: Apr 2004
Posts: 77 USA
Cactus
OP
Junior Member
|
OP
Junior Member
Joined: Apr 2004
Posts: 77
USA
|
Thank You so much, but now when I load the next level all of the panels I made in my main script for for level 2 dont show up. Is it still using the same main script from the last level? if so how do I load the main script for level two?
HI
|
|
|
Re: changing the level once my character reaches a certain posiiton
[Re: Xarthor]
#234591
11/03/08 19:38
11/03/08 19:38
|
Joined: Apr 2004
Posts: 77 USA
Cactus
OP
Junior Member
|
OP
Junior Member
Joined: Apr 2004
Posts: 77
USA
|
Ok I used the seconed aproach and it worked, but now when the player shoots at the level change object the level changer turns off. Still using A5 templates.
HI
|
|
|
Re: changing the level once my character reaches a certain posiiton
[Re: Cactus]
#234620
11/03/08 21:26
11/03/08 21:26
|
Joined: Jul 2002
Posts: 4,436 Germany, Luebeck
Xarthor
Expert
|
Expert
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
|
function LevelChanger_event()
{
if(event_type == event_entity || event_type == event_impact)
{
if(you == player)
{
my.enable_entity = null;
my.enable_impact = null;
level_load("level2.wmb");
}
}
}
This makes sure that events are only turned off if the player hits the entity. Hope this works.
|
|
|
Re: changing the level once my character reaches a certain posiiton
[Re: Xarthor]
#234653
11/04/08 00:09
11/04/08 00:09
|
Joined: Apr 2004
Posts: 77 USA
Cactus
OP
Junior Member
|
OP
Junior Member
Joined: Apr 2004
Posts: 77
USA
|
no that did'nt work, but thanks anyway. I guess I'll just figure it out.
HI
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|