Jump to content


Jump to certain position after restarting room?

  • Please log in to reply
4 replies to this topic

#1 adhgarra


    GMC Member

  • GMC Member
  • 90 posts
  • Version:GM:Studio

Posted 28 September 2011 - 04:06 AM

Ok so I'm making a crash bandicoot fan game and I was wondering could you make an object appear at a certain place wen the room restart without using the persistent option.. Cause I want everything other object to jump to start except the main character.
  • 0

#2 kremling


    GMC Member

  • GMC Member
  • 164 posts

Posted 28 September 2011 - 04:09 AM

Do you mean like if the main player dies, he will restart to like a check point, and you want all the object objects in the room back to their original spot?
  • 0

#3 adhgarra


    GMC Member

  • GMC Member
  • 90 posts
  • Version:GM:Studio

Posted 28 September 2011 - 04:21 AM

  • 0

#4 Hazard94


    GMC Member

  • GMC Member
  • 56 posts
  • Version:GM8

Posted 28 September 2011 - 05:00 AM

if the objects you want to restart are not destroyed during the game try instead of game_restart() when the player dies:
   if object_index!=obj_mainplayer // or whatever the main player's object index is (the ! means not)
   { x=xstart; y=ystart}

But if the instances are destroyed, this would be a little harder I think

Edited by Hazard94, 28 September 2011 - 05:00 AM.

  • 0

#5 Yal


    Even though the GMC may be gone, our love will prevail eternally

  • Global Moderators
  • 11774 posts
  • Version:GM:Studio

Posted 28 September 2011 - 07:53 AM

This is very easy and it's something I use a lot.

In the Create event of the title screen, define three global variables:
global.checkpoint =-1
global.sx = 0
global.sy = 0

When you collide with a checkpoint, let the player perform this code:
global.sx = x
global.sy = y
global.checkpoint = room

in the Create event of the player, also put this:
if(global.checkpoint == room){
  x = global.sx
  y = global.sy

Note: you might want to set global.checkpoint to -1 again when the player reaches the goal of the level.

If this helps you, please show me your gratitude by trying out my games ;)

Edited by Yal, 28 September 2011 - 07:54 AM.

  • 0

- The above is my personal opinion and in no way representative of Yoyogames or the GMC, except when explicitly stated -


Open this spoiler for my games:


Some useful game engines, music and other resources at affordable prices:

My collection of game resources at itch.io


New user? Can't draw but want to look unique? You can request a new avatar in this thread!