Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

"Player Teleport" is not working after "map goto" in the same script.

I have a map that will serve as hub area and beside of the exit that starts the mission. i made severel other exits to different maps (a bar for example).

To get to the right place at the hub area, i used a trigger at the bar exit with this script:

map goto 1

player teleport 19 4

map return

But instead of spawning the player at x19 y4

It spawns the player at the default player start.


I used player teleport before, so i know it works in general. But not directly after loading a map?

i tried something similar with the same results a while ago. i ended up just making copies of the hub level with different start points. maps are only 129k so not a big deal. but if you decide to change up tiles and such in your hub level..... gotta change it in each copy of the map.

Yeah, my Hub is far from finishes and changing every map each time would be a pain.

But i keep that in mind, if i finally finished the hub.

(1 edit)

I also have several copies on my PC. Just don't call them.

It will not work like that. 

Map goto just loading a new level. All information about player placement should be stored in map script of that new level. 

so theoretically he could have the level he just beat change a variable, and if a = 1 then player teleport whatev, if a = 2 then player teleport whatever els

Hm, worth to try! 

I will try this next time i can work on the game. Thanks man.

(4 edits)

So, i tried to use variables in the map scripts.

The game just crashes on loading the second map.

Script in first map:

global.value=1


second map:

if $global.value == 1 {

player teleport 5 24}

map return



EDIT:

Forget it. i had a wrong formating.

But even with the right formating, it does not teleport the player to the coordiantes.


second map:

if $global.value == 1 {

player teleport 5 24

}

map return


Last EDIT:

So, i figured it out. but its kind of janky.

Hub map has NOTHING in the map script an NO player start!

load the map, without start object and figure out the rough location (sadly its not x0 y0 more between x3 y3 and x4 y4).

Put some triggers at that coordiantes with a script like this:

player teleport 5 24 //initial starting position

if $global.value == 1 { //global variable is set in the second map

player teleport 19 4 //position of the player after exiting second map

}

map return

In my case the Map i want to go to and back to the hub is a bar.

In the map script of the bar set  the global variable to 1

global.value=1


Put a trigger at the exit of the bar to load the Hub map.

I haven't touched scripts in a while. I think there was a problem with coordinates which should be fixed in the newest unreleased version.

Will be updated.

Someday.