How do I create an advanced checkpoint

Get help using Construct 2

Post » Tue Oct 18, 2016 9:52 am

Hello

I'm trying to make a checkpoint that changes its animation whenever that checkpoint is active, which means if you would have two checkpoints near, you could tell by an animation which one is activated for the loading data.

Now the problem is, how can I trigger this? I'm basically using the save/load function built in C2, when player collides with the checkpoint saves the game. On dead load from save.

If I were to have three checkpoints how can I make one of them to change its animation to "Active" based on the save/load.

Thanks
B
14
S
5
Posts: 248
Reputation: 1,705

Post » Tue Oct 18, 2016 1:28 pm

Here is an idea: make a global variable that saves the UID of the checkpoint you reach. I am pretty sure that global variables don't reset when the layout restarts or loads. That way, you can say which one you want to change the animation of.
B
8
S
1
Posts: 20
Reputation: 449

Post » Tue Oct 18, 2016 3:09 pm

DerpyDev wrote:Here is an idea: make a global variable that saves the UID of the checkpoint you reach. I am pretty sure that global variables don't reset when the layout restarts or loads. That way, you can say which one you want to change the animation of.


Global variable was my idea but I dont really know how to make it work
B
14
S
5
Posts: 248
Reputation: 1,705

Post » Tue Oct 18, 2016 6:04 pm

@Smileh,
I don't know if the UID of the object would work or not but I would add an instance variable to the checkpoint object. You can then give every checkpoint a unique ID (Value) which will be put inside the instance variable.
When the player reaches a checkpoint, you can save the instance variable of that checkpoint in localstorage or simply with the built in save/load function.
Then you just add a condition which checks every single checkpoint if it contains the saved value. If it's the same, that should be the last checkpoint and you can change its animation to active. Every other checkpoint can be set to the inactive animation.
I hope this helps! :)
Image
B
5
S
3
Posts: 193
Reputation: 1,063

Post » Tue Oct 18, 2016 7:37 pm

aquadijoib wrote:@Smileh,
I don't know if the UID of the object would work or not but I would add an instance variable to the checkpoint object. You can then give every checkpoint a unique ID (Value) which will be put inside the instance variable.
When the player reaches a checkpoint, you can save the instance variable of that checkpoint in localstorage or simply with the built in save/load function.
Then you just add a condition which checks every single checkpoint if it contains the saved value. If it's the same, that should be the last checkpoint and you can change its animation to active. Every other checkpoint can be set to the inactive animation.
I hope this helps! :)


Can I do this with the save/load function as well? I have no idea how to datastorage
B
14
S
5
Posts: 248
Reputation: 1,705

Post » Wed Oct 19, 2016 12:50 pm

Yes you can use the save function aswell. You just have to set the instance variable (or animation frame :)) of the object and then save the whole game state.
If you use the save/load function you don't need to do that though, because it will save the whole state of the game.
Here is an example capx with a working waypoint system:
https://drive.google.com/file/d/0B7r2WY ... sp=sharing

In my example you actually don't even need to use an instance variable. I just used the animation frame of the object (You can have an activated animation frame and a deactivated one). 0 is deactivated and 1 is activated.

I hope this helps! :D
Image
B
5
S
3
Posts: 193
Reputation: 1,063

Post » Wed Oct 19, 2016 12:57 pm

aquadijoib wrote:Yes you can use the save function aswell. You just have to set the instance variable (or animation frame :)) of the object and then save the whole game state.
If you use the save/load function you don't need to do that though, because it will save the whole state of the game.
Here is an example capx with a working waypoint system:
https://drive.google.com/file/d/0B7r2WY ... sp=sharing

In my example you actually don't even need to use an instance variable. I just used the animation frame of the object (You can have an activated animation frame and a deactivated one). 0 is deactivated and 1 is activated.

I hope this helps! :D


Thank a lot for the example. I heard pick nearest can cause performance issues, can I use a variable instead? I feel stupid. I figured out harder things and now simpler stuff confuses me lol
B
14
S
5
Posts: 248
Reputation: 1,705

Post » Wed Oct 19, 2016 1:09 pm

You could probably use the For each loop to check every checkpoint if it is touching the player. If that is true just set the animation frame of that checkpoint to 1 (active).
:D
Image
B
5
S
3
Posts: 193
Reputation: 1,063


Return to How do I....?

Who is online

Users browsing this forum: Lordshiva1948, Yahoo [Bot] and 53 guests