How to make Checkpoints?
#1
Posted 30 September 2010 - 08:37 PM
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)
#2
Posted 30 September 2010 - 08:42 PM
#3
Posted 30 September 2010 - 08:56 PM
Thanks for replying, I had a go at doing this but couldn't get it to work.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.
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.
#4
Posted 30 September 2010 - 09:23 PM
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.
#5
Posted 30 September 2010 - 11:36 PM
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!
#6
Posted 01 October 2010 - 12:28 PM
thanks for the help, i think i did everything right but it came up with an error,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!
___________________________________________
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]
#7
Posted 01 October 2010 - 10:00 PM
x=objCheckPointGot.x
y=objCheckPointGot.y
#8
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!
#9
Posted 01 April 2013 - 01:32 AM
Thanks in advance!
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











