Problem with checkpoints // Solved

Non-platform specific questions.

Problem with checkpoints // Solved

Postby bilvyy » Fri Jul 22, 2011 12:01 am

I used Bee-Ant's tutorial on making checkpoints and it's working all well and fine for me, but I do have a problem. I know what's causing it but I don't know the solution.

I have doors in my game and in order for my character to walk/teleport through each one, I use the DestroyActor and CreateActor event at each doorway. But now, whenever my player walks through a door, he appears at the save point.

It's like the CreateActor event at the checkpoint is interfering with my doorways. Is there anything I can do to fix this?
Last edited by bilvyy on Sun Jul 24, 2011 2:34 am, edited 1 time in total.
bilvyy
 
Posts: 23
Joined: Wed Feb 16, 2011 2:04 am
Score: 0 Give a positive score

Re: Problem with checkpoints

Postby skydereign » Fri Jul 22, 2011 6:20 am

Well, as you said the problem is the use of create actor and destroy actor. So, I'd say the fix is to not destroy the actor when you jump between doors. What code are you using to know where the next door to jump to is? Because depending on how it is setup you could just change the actor's xy position to the other door.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Problem with checkpoints

Postby Bee-Ant » Fri Jul 22, 2011 4:50 pm

I won't use Destroy-Create system for the teleport thing...
I would just change the Player x and y position.

For example, there're 3 doors...
"Door1" will send you to "Door2", "Door2" will send you "Door3", and "Door3" to "Door1"...

So, here's the code for each door...
Door1 -> Collision -> from Player -> Script Editor:
Code: Select all
collide.x=Door2.x;
collide.y=Door2.y;
view.x=Player.x-320; //supposed you have 640 width
view.y=Player.y-320;

Door2 -> Collision -> from Player -> Script Editor:
Code: Select all
collide.x=Door3.x;
collide.y=Door3.y;
view.x=Player.x-320; //supposed you have 640 width
view.y=Player.y-320;

Door3 -> Collision -> from Player -> Script Editor:
Code: Select all
collide.x=Door1.x;
collide.y=Door1.y;
view.x=Player.x-320; //supposed you have 640 width
view.y=Player.y-320;

Those are the most unefficient way, but worth to try than stuck in a bug.

And here's the more efficient way. I will just clone the door, and make a library for the next-door-destination id.
Put this in global code:
Code: Select all
#define door_total 6 //supposed you have 5 doors in total, I always use max_value+1 to avoid array out of bound
int next_door[door_total]={1,2,3,4,0};

It will connect:
Door.0 to Door.1
Door.1 to Door.2
Door.2 to Door.3
Door.3 to Door.4
Door.4 to Door.0

And put this in Door -> Collision -> From Player -> Script Editor:
Code: Select all
Actor *check;
char str[32];
sprintf(str,"Door.%i",next_door[cloneindex]);
check=getclone(str);
collide.x=check->x;
collide.y=check->y;
view.x=Player.x-320;
view.y=Player.y-320;

With this method, you can have 999 doors without 999 codes for each door. Only use one code above to manage them all :)
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Problem with checkpoints

Postby schnellboot » Fri Jul 22, 2011 4:58 pm

just a little addition to bee's code
you can use instead of
Bee-Ant wrote:
Code: Select all
view.x=Player.x-320;

this
Code: Select all
view.x=Player.x-view.width/2;


the code will work for all resolutions then
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: Problem with checkpoints

Postby bilvyy » Sun Jul 24, 2011 12:28 am

Bee-Ant wrote:I won't use Destroy-Create system for the teleport thing...
I would just change the Player x and y position.

For example, there're 3 doors...
"Door1" will send you to "Door2", "Door2" will send you "Door3", and "Door3" to "Door1"...
. . .


Thank you for this (: I was weary at first, having to change the codes of all my doors, but this is turning out to be easier than I thought and will make it easier to keep everything organised. I've gone with the first code you supplied me, it seems to be working, and I hope this should fix my checkpoint issue once I get to that point of my game. Thank you so much.
bilvyy
 
Posts: 23
Joined: Wed Feb 16, 2011 2:04 am
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest