Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Môsi

A tiny game editor you can use on your phone or in your browser · By sg

how to make the player teleport randomly?

A topic by ondr created Aug 17, 2023 Views: 179 Replies: 2
Viewing posts 1 to 2

i was wondering how do i teleport the player to a random room and a random position?

i tried something like this: 

{move-avatar {random 0 16}}

for teleporting randomly but for some reason it doesn't work.

Hey buddy, not sure if you figured it out yourself, but you were nearly there. To move the player to a random point in the same room you'd have to do:

{move-avatar {random 0 16}{random 0 16}}

You need to do it twice for the X and the Y value of the player's position.

For teleporting them to a different room, it's probably best to do something like:


{set-var randomRoom {random 0 6}}

{if

      {eq 

            {var randomRoom}

            2

      }

}

{move-avatar room2 {random 0 16}{random 0 16}}

{/if}

And then do an if statement for all the potential room they could get taken to.

(+1)

Oh, thank you very much!