Help with creation code.

B

Bannadon91

Guest
So I'm trying to make a simple teleportation object but the problem is I also want the same object to be in two different places in the same room, so I'm using the creation code to do it but it wont seem to work. I have three of the same objects and two of them restart the room while the the other is supposed to teleport the player in a different area in the same room. I use if(place_meeting,x,y,obj_player){room_restart} and for the actual teleportation I'm using if place_meeting,x,y,obj_player {x=310 y=101}
 

Sk8dududu

Member
What isn't working? The teleporting or the room restarting?
I'm assuming you've put this in the step event of obj_player?
 

FrostyCat

Redemption Seeker
Collision checks are not Create event nor Creation Code material, they're Step event material. And your code isn't syntactically valid to start with. The correct form would have been obvious if you read the Overview section on GML and the Manual entry for place_meeting().
Code:
if (place_meeting(x, y, obj_player)) {
  room_restart();
}
Code:
if (place_meeting(x, y, obj_player)) {
  obj_player.x = 310;
  obj_player.y = 101;
}
You need to stop excusing the random nonsense you've been writing in the name of being new, and it's not like you haven't been told what to do before. Go through a basic GML tutorial like this one to learn GM's building blocks, and also read the Overview section on GML. You can't master coding by guessing.
 
Last edited:
B

Bannadon91

Guest
What isn't working? The teleporting or the room restarting?
I'm assuming you've put this in the step event of obj_player?
No I haven't I assumed it was all in the creation code for there was multiple of the same object.
 
Top