Page 1 of 1

checkpoints

PostPosted: Thu Aug 13, 2009 5:24 am
by skatebored0m
Hey
I need some help making checkpoints. I dont know how to save the coordinates of the checkpoint when you collide with it and load it after the HP bar goes to 0. If someone could explain that along or give me a link with a simple demo or something it would help a lot.

Re: checkpoints

PostPosted: Thu Aug 13, 2009 8:07 am
by skydereign
I'll do both. First, you need to create two variables, in the demo I named them xCheck, and yCheck. Now these are the coordinates of the last checkpoint hit. To set these, add a collision event with the checkpoint actor, might as well set the collision not to repeat. Next you should put this code
Code: Select all
xCheck=collide.x;
yCheck=collide.y;


Your positions are now set. Now in the demo I had mouse button down right to destroy the actor, but your health depletion will do the trick. Then on the event of DestroyActor, you should recreate the actor with the xy coordinates as xCheck and yCheck, make sure that position is set to true, not relative to the creator. That should do the trick. To explain the demo, the red actor is the player, it will only be red when in game mode. Now you can drag him around by holding left click, the green actors are the checkpoints. Right clicking will destroy the actor and make a new one wherever the last checkpoint he collided with was. If you any questions, or this doesn't work for you, I'll see what I can do.

Re: checkpoints

PostPosted: Thu Aug 20, 2009 8:59 pm
by skatebored0m
The way I have my game set up, the view has Player1 set as it's parent so that Player1 is always in the center of the view. Whenever Player1 is destroyed and recreated at the checkpoint, the view no longer follows Player1. Can anyone fix this? Ill try to attach what I have in my game so people can see exactly what the problem is. (just walk right into the water to kill Player1).

Re: checkpoints

PostPosted: Thu Aug 20, 2009 9:10 pm
by skydereign
Well, it doesn't look like there is a checkpoint system setup, but this is what you should do. On the create actor event of your player, add this to the script editor, or just click the ChangeParent.

player->Create Actor->Script Editor
Code: Select all
ChangeParent("view", "Event Actor");


You would do this for just the view, as anything else should be parented to the view.