Jump to content


Photo

How to make Checkpoints?


  • Please log in to reply
9 replies to this topic

#1 armed_combat

armed_combat

    GMC Member

  • New Member
  • 5 posts

Posted 30 September 2010 - 08:37 PM

Hey all,

I'm wondering how to create checkpoint's for a level.

At the moment i have it so that when the caracter looses a life it "jumps to the start position", but because the level is quite big I would like to make a checkpoint for the character to jump to instead of going all the way back to the beginning of the level.

I don't know how I would go about this and would appreciate some advice. Thanks

(D+D if please, I don't know how to use GML yet)
  • 0

#2 Nial8r

Nial8r

    GMC Member

  • New Member
  • 341 posts

Posted 30 September 2010 - 08:42 PM

Well make an invisible object, tall and thin and make it not solid, then on collision with character set a variable checkpoint1=1 (or whatever) then n 2, checkpoint2=1 checkpoint1=0 ect, then on death, if checkpoint1=1 goto checkpoint1 if checkpoint 2=1 goto checkpoint 2 ect.. tell me if i need to be clearer.
  • 0

#3 armed_combat

armed_combat

    GMC Member

  • New Member
  • 5 posts

Posted 30 September 2010 - 08:56 PM

Well make an invisible object, tall and thin and make it not solid, then on collision with character set a variable checkpoint1=1 (or whatever) then n 2, checkpoint2=1 checkpoint1=0 ect, then on death, if checkpoint1=1 goto checkpoint1 if checkpoint 2=1 goto checkpoint 2 ect.. tell me if i need to be clearer.

Thanks for replying, I had a go at doing this but couldn't get it to work.
if its not too much trouble could you please explain it a bit clearer, thanks

Edited by armed_combat, 30 September 2010 - 09:07 PM.

  • 0

#4 Nial8r

Nial8r

    GMC Member

  • New Member
  • 341 posts

Posted 30 September 2010 - 09:23 PM

Alright :)
First you need some tall and skinny objects, but not visible, and not solid. Name them CP1, CP2, and CP3.

Where ever you have the restart on die code, put this instead of restart level, but keep any other properties you may have
if CP1check=1
{
player.x=CP1.x //you can set your own coordinates relative to CP1
player.y=CP1.y //change player to the name of your character of course
}

if CP2check=1
{
player.x=CP2.x
player.y=CP2.y
}

if CP3check=1
{
player.x=CP3.x
player.y=CP3.y
}

in the collision event of the CP1 with the player:
CP1check=1
CP2check=0
CP3check=0

in the collision event of the CP2 with the player:
CP1check=0
CP2check=1
CP3check=0

in the collision event of the CP3 with the player:
CP1check=0
CP2check=0
CP3check=1

Now ovbiously you can make as many checkpoints as you want. Tell me if you need anything else or if I forgot something.

Edited by Nial8r, 30 September 2010 - 09:30 PM.

  • 0

#5 ShadowKarma

ShadowKarma

    GMC Member

  • New Member
  • 61 posts

Posted 30 September 2010 - 11:36 PM

Here's how I usually do it:

Create two objects. objCheckPoint, and objCheckPointGot, and change the color of objCheckPointGot's sprite.

In objPlayer's create event, insert this code:
checkpoint=0
death=0

In objPlayer's collision event with the player, insert this code:
checkpoint=1

In objCheckPoint's step event, insert this code:
if objPlayer.checkpoint = 1 {
object_index=objCheckPointGot
}

In objPlayer's collision event with anything that kills you, insert this code:
if checkpoint = 1 {
x=objCheckPointGot.x,y=objCheckPointGot.y
}
else {
x=xstart
y=ystart
}

Hope it helps let me know if you have any further problems!
  • 0

#6 armed_combat

armed_combat

    GMC Member

  • New Member
  • 5 posts

Posted 01 October 2010 - 12:28 PM

Here's how I usually do it:

Create two objects. objCheckPoint, and objCheckPointGot, and change the color of objCheckPointGot's sprite.

In objPlayer's create event, insert this code:
checkpoint=0
death=0

In objPlayer's collision event with the player, insert this code:
checkpoint=1

In objCheckPoint's step event, insert this code:
if objPlayer.checkpoint = 1 {
object_index=objCheckPointGot
}

In objPlayer's collision event with anything that kills you, insert this code:
if checkpoint = 1 {
x=objCheckPointGot.x,y=objCheckPointGot.y
}
else {
x=xstart
y=ystart
}

Hope it helps let me know if you have any further problems!

thanks for the help, i think i did everything right but it came up with an error,
___________________________________________
FATAL ERROR in
action number 2
of Collision Event with object Obj_Enemy
for object Obj_charachter:

COMPILATION ERROR in code action
Error in code at line 2:
x=objCheckPointGot.x,y=objCheckPointGot.y

at position 22: Unexpected symbol in expression.

Im not sure what it means I was hoping if its not too much hassle you could help me out? cheers

[I know its probably really simple but I don't really know anything about GML sorry]
  • 0

#7 Nial8r

Nial8r

    GMC Member

  • New Member
  • 341 posts

Posted 01 October 2010 - 10:00 PM

oh, dont have a comma there, put a return instead.

x=objCheckPointGot.x
y=objCheckPointGot.y
  • 1

#8 cherrim98

cherrim98

    GMC Member

  • New Member
  • 18 posts
  • Version:GM8.1

Posted 31 March 2013 - 11:11 PM

Hi I'm new to the forums. But not new to gamemaker. I know a lot about it but I need help with checkpoints! It is a Crash Bandicoot Fan Game (availible to download here: http://sandbox.yoyog...-demo-cherrim98) i have an object called obj_crash (obviously) and obj_crash_spin (for spinning). In the step event of obj_crash, he can jump on crates. One of the Crates is the checkpoint crate which has the effect and gets broken when crash spins or jumps on it. The problem is when he dies, the checkpoint crate does not activate. Also, i need to make sure he does not respawn near the checkpoint when he has an Aku mask (a mask that protects him from 1 or 2 hits.) And when he is invincible and touches a danger, you do not glitch the game. I have 2 parents called obj_hurt_crash_parent, and obj_kill_crash_parent. Try the game so you know what I mean. Thanks in advance!


  • 0

#9 LordDestroyer

LordDestroyer

    GMC Member

  • New Member
  • 9 posts
  • Version:Unknown

Posted 29 June 2014 - 12:31 PM

It is easy. Use THIS when touching a checkpoint and on room start: (touching means collision event, room start = room start event.)

global.xx = x
global.yy = y

And THIS use after touching a laser / spike /... Just touching something bad: (touching means collision event)

x = global.xx
y = global.yy

(Both codes goes under your object representing player)

 

But you may fail with this if your game is a platformer game. Then use "speed = 0" on beggining of the code, getting this:

speed = 0
global.xx = x
global.yy = y
speed = 0
x = global.xx
y = global.yy

EDIT:

Or you can make checkpoint saving more info (speed, score, health...)

Like are coordinates saved, you can save anything else same way.

 

global.sco = score // in the first code

 

score = global.sco // in the second code


Edited by LordDestroyer, 29 June 2014 - 12:38 PM.

  • 0

#10 BlessHayGaming

BlessHayGaming

    YouTube Content Creator

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

Posted 29 June 2014 - 01:17 PM

Create a variable in your player:

:GM072: cObj = -1;

 

Create a checkpoint object

 

Then, in your player, when "dying":

:GM073: if cObj = -1

:GM063:

:GM012: Jump to start

:GM066:

:GM064:

:GM063:

:GM004: Jump to cObj.x & cObj.y

:GM066:

 

In collision with checkpoint

:GM072: cObj = other.id

 

 

 

 

 

This should work :)


Edited by BlessHayGaming, 29 June 2014 - 01:17 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users