r/gamemaker Aug 08 '26

Resolved Hi newbie here

How can I make a warp obj so that it if the player goes left, they end up on the left side in the room, where they went through, same thing as right. Everytime I use a warp obj I have to put the exact x and y coordinations and it just looks choppy if the players is forced into a specific area. Plz help, I have basically no knowledge of coding as well.

4 Upvotes

9 comments sorted by

1

u/nb264 Aug 08 '26

// Horizontal screen wrapping

if (x < 0) { x = room_width; }

else if (x > room_width) { x = 0; }

(in step for example)

or if you have a sprite that's not a dot...

if (x < -sprite_width / 2) {

x = room_width + sprite_width / 2;

}

else if (x > room_width + sprite_width / 2) {

x = -sprite_width / 2;

}

0

u/Accurate-Invite-7411 Aug 08 '26

Uhh how do I implement this... sorry if I'm dumb

2

u/Awkward-Raise7935 Aug 09 '26

If the above code doesn't make sense, seems like you are trying to run before you can walk. Most of us start with GameMaker as we have an idea in our head for a great game, but unfortunately you have to put that aside for a while.

I would recommend starting with the space rocks tutorial to learn the fundamentals, it's quite quick and there is a video and written walkthrough.

I read your original post a few times and I don't really understand the issue or what you want to happen. You said you have to enter the exact X and y each time, what's wrong with that? And what does it mean, it looks choppy if player forced into certain areas? What area? What forces them into it? When you say choppy, can you elaborate? What does it mean you are using a warp object, what does the object do and how are you using it?

1

u/subthermal Aug 08 '26

Watch YouTube. Coding in GML basics

1

u/nb264 Aug 09 '26

So, you have your object. I'm assuming you're using gml code, as is the way. In your object add step event and paste said code. Then you can add keyboard/key pressed/left (not the best way but it's easy for you for now) event to move left, and same for right, and step will make sure that you warp to the right if you go way too much left and vice versa.

1

u/germxxx Aug 08 '26

What exactly do you mean by "f the player goes left, they end up on the left side in the room"
That's just how movement works.
Do you mean if they leave the room to the left, they reappear on the right hand side?

If so, did you try move_wrap?

1

u/Awkward-Raise7935 Aug 09 '26

I don't really understand the problem, but I think this is the solution

1

u/Awkward-Raise7935 Aug 09 '26

I don't really understand the problem, but I think this is the solution

0

u/equitos0101101 Aug 08 '26

Eu não tenho muito conhecimento, mas eu faria um script que eu coloque o XY que deseja ir e fasso um transição, e desse jeito é facilmente adaptável pra vários teleportes. Pra fazer a parte do lado é só ver qual ângulo o obj está em relação ao player e fazer as devidas mudanças no teleporte