wrap outside the room - objects disappear

X

Xysterdust

Guest
I'm new to GM and I've just finished the asteroid tutorial.

In the tutorial you set up a spawner object to spawn asteroids when no more asteroid instances exist.

During a playthrough I reached a point where there were no more visible asteroids, but the game was not respawning the instances. I had seen the last mini asteroid go off the screen in the corner and never came back.

Testing this, I can make my player object(the space ship) disappear as well. simply move the object off the screen towards the corner and have it move horizontally when it is no longer visible on the top or bottom borders. Pretty much try to intentionally make it outside of the room when approaching a corner. Then the object disappears and is out of the room.

At this point I cant get the object back into the room. pressing up(speeding up) and trying all directions do not work. It is now "stuck" outside of the room.

I can reproduce this easily.

Is this the way its supposed to work? Is there a better way to code this with the same intent of having the object wrap outside the room?

I created a video of the problem.
 
Last edited by a moderator:
X

Xysterdust

Guest
Latch, thank you very much.

Originally I setup an Outside Room event to use the "wrap screen" prefab action. I changed it to execute code and used the command you suggested. At move_wrap(1,1,32) I can still reproduce the problem. At move_wrap(1,1,10) I can as well. But at move_wrap(1,1,1) I can't reproduce it. It seems "fixed", but obviously the wrap happens a bit suddenly and doesnt feel exactly smooth.

However, this is much more preferred than losing an object.

I would love if anyone else can chime in on this and maybe explain whats happening.

thanks again Latch. Very helpful!
 
W

WingedRobot

Guest
I am having the same issue, but have found it's a little more complicated than the object simply being deleted. I've found, because I have another object (a thruster animation for effect) as a child to my "Asteroids ship" that sometimes the thruster effect will disappear when wrapping around the screen. I then found I could make only the ship disappear, but not the thruster animation. The thruster animation would continue showing up behind where I expected the ship to be, and the ship would continue flying around as expected, just invisible. If I had to guess, based on some testing, I believe the game makes an object invisible as soon as it's completely off-screen before jumping it to the other side (perhaps even when it's at rest) and setting it visible again. However, if you don't pass and jump the object to the other side of the screen, the object stays invisible, but still active. Unfortunately setting visible to true every step doesn't seem to fix this, and worse for me it seems to also set all children to visible at all times. I'm not sure what could be done to fix it.
 
D

dj_midknight

Guest
If you use a center point x,y for your asteroid you can easily do a step event translation.

if(x > room_width) x = 0;
if(x < 0) x = room_width;
repeat for the y axis.

This will let the asteroid get 51% out of bounds before jumping it across.
 
I

icuurd12b42

Guest
Use YT next time. we cant make the stupid vimeo video full screen so we cant see your code...

anyway, move_wrap in the END step is what you need., no in the outside room or outside view event.
 

TheouAegis

Member
The Outside Room and Outside View events only fire one time. So if you hit them at just the right position, they'll fire on one side but not the other and then you're stuck in limbo.
 
M

Mitoni

Guest
I had this same issue. It seemed to happen if the object was far enough outside of the screen, but slow enough to not immediately pop on the other side. I even had it happen with my player once.

I abandoned using the built-in screen wrap, and just wrote one, as shown above, as a script, which i call in each of the objects (player and asteroid) step events.

Code:
///scr_screen_wrap
if (x > room_width)
{
    x = 0
}

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

if (y < 0)
{
    y = room_height;
}

if (y > room_height)
{
    y = 0
}
 
D

DragonHorse

Guest
Use YT next time. we cant make the stupid vimeo video full screen so we cant see your code...

anyway, move_wrap in the END step is what you need., no in the outside room or outside view event.
Sorry to hijack, but I experienced the same issue, and your fix worked. Are you able to say why it has to be that way? The fact that it works is useful but it would be good to understand why it works.

The drag and drop 'Wrap Screen' action works correctly when associated with the 'Outside Room' event and I'm curious to understand why that works, but code doesn't with 'Outside Room'

I'm not attached to a given approach, I just like to understand why :)
 
I

icuurd12b42

Guest
Sorry to hijack, but I experienced the same issue, and your fix worked. Are you able to say why it has to be that way? The fact that it works is useful but it would be good to understand why it works.

The drag and drop 'Wrap Screen' action works correctly when associated with the 'Outside Room' event and I'm curious to understand why that works, but code doesn't with 'Outside Room'

I'm not attached to a given approach, I just like to understand why :)
On occasion you need 2 steps to correctly wrap the instance, like in the case of moving out of a corner... and since gms:1 outside room only triggers once, it skips a beat. because wraping the instance down places the instance below the screen but it's movement does not make it enter the screen on the next move...

upload_2017-3-6_20-42-42.png
https://www.dropbox.com/s/cuyoft2upp63hla/outsideroom.gmz?dl=1
 
G

GameMaking_Pleb'n'Noob

Guest
Um, so I might have a similar problem (hope it's fine that I'm replying here btw). So I'm making a simple game where there are four rooms (Main, Left, Right, Finish), and the rooms on the sides have "buttons" to select an answer. But I can't check to see if all of the game works because when I start to transition to another room (using invisible markers with the collision event and the different room action), the player sprite disappears... I'm not sure what's the room nor what to do.
 

TheouAegis

Member
Use the debugger to track the position of your player (and make sure it still exists). Or put in the player's Draw GUI event;

draw_text(0,0, string(x) + " , " + string(y));
 
Top