Moving player to an object

Hi
I have no knowledge of coding and work online only.
My problem is. How do I move the player by teleportation to the location of an object that is not a room.
Player pulls lever in certain room.
Player is teleported to the room where a box has been left ( the box may have been left anywhere)
The code view shows MoveObject ( player, box)
This does not work . How should I do it please. Parent of box possibly?
I bet there’s an easy answer , I just don’t know coding


The code view shows MoveObject ( player, box)

That would put the player inside the box.

Parent of box possibly?

Yep, that's what you want.

MoveObject (player, box.parent)

(Actually, I'd recommend MoveObject (game.pov, box.parent) in most cases. In most simple games, player and game.pov mean the same thing. But using player is a bad habit to get into, because in some more complex situations it might not work)


If there's a chance the box might be inside another container, and you want to move the player to the room rather than the container in that case, you'd want:

MoveObject (game.pov, ObjectListItem (FilterByAttribute (ListParents (box), "isroom", true), 0))

(Getting a list of all the objects the box is inside, filtering that list to just the rooms, and then taking the first room from that list. This will give an error if the box isn't in a room - if that's possible then you should check for it first)


Log in to post a reply.

Support

Forums