Welcome to the forum, yikson.
You have several solutions but I will mention two:
Solution 1) Create an event
Create an event called "door" and place it on Tiled Map Editor. You have the explanations here: https://docs.rpgjs.dev/guide/create-event.html#create-a-character-shared-mode
Your event is the following:
import { RpgEvent, EventData, RpgPlayer } from '@rpgjs/server'
@EventData({
name: 'door'
})
export class DoorEvent extends RpgEvent {
onPlayerTouch(player: RpgPlayer) {
player.changeMap('inside_map') // put here the name of the new map
}
}
I used the onPlayerTouch hook
Remember to add the event in the map (see the guide)
Solution 2) Creating a shape
Another solution is to create a shape. You have the guide that tells you how to do it. Give a name to the shape (in Tiled Map Editor, go to the shape properties, and put the name "door"
In the file src/modules/main/server/player.ts
:
import { RpgPlayer, RpgShape, RpgPlayerHooks } from '@rpgjs/server'
export const player: RpgPlayerHooks = {
onInShape(player: RpgPlayer, shape: RpgShape) {
if (shape.name == 'door') player.changeMap('inside_map') // put here the name of the new map
}
}
âšī¸ Note
The event is interesting to put a graphic or an animation on an event.
If you just want to make an interaction, the shape is surely the fastest way
It's up to you to choose