Game Development Community

Respawn on Fall

by Adam Dorsey · in Technical Issues · 11/20/2006 (12:23 pm) · 9 replies

Whats up guys,

Doing a super simple platform level as my first attempt at a game.

Player spawns, and jumps from platform to platform to make it to final objective. At one point he'll be crossing a large chasm via a wooden bridge that'll be broken in the middle.

How would I do a simple script so that if he falls in the chasm he respawns back at the start? (or maybe if he falls off a high enough platform it kills him)

I have no idea hwere to start so keep the description in total noob terminology...

Thanks, any help is greatly appreciated.

AD

#1
11/20/2006 (12:42 pm)
Put a trigger at the bottom of the chasm to respawn him.
- there's lot's of documentation on triggers.
#2
11/20/2006 (1:13 pm)
If you had only one respawn sphere, your player would automaticaly respawn at the start.

Useing the trigger idea, you could have spawn markers in lots of locations along the route,
and as the player passes the trigger area you could set a variable. And when the player
dies get respawned to the correct spawn sphere.
#3
11/20/2006 (1:43 pm)
It depends on your level design. If you have chasm openings at drastically different heights, you might need to use triggers, but if they are all about the same height you could have one large trigger across the bottom of all the chasms.

As for falling damage, you can just count the ammount of time the player is in the air and apply damage based on that.
#4
11/20/2006 (8:46 pm)
Thanks for the advice so far, got me started, but I can't get the .spawnPlayer function to work...but I may be missing something.

Here's what I have: (in my triggers.cs file, which is be executed in game.cs)

datablock TriggerData( SpawnTrigger )
{
tickPeriodMS = 100;
};

function SpawnTrigger::onEnterTrigger( %this, %trigger, %obj )
{

%client.spawnPlayer();
}




The message I get says:

Unable to find object ' ' Attempting to call function 'spawnPlayer'

Any ideas?
#5
11/20/2006 (10:47 pm)
I haven't tested it, but try this for the body of onEnterTrigger():
%point = pickSpawnPoint();
   %obj.setTransform(%point);
#6
11/21/2006 (1:43 am)
Change
%client.spawn
to
%obj.spawn


%client doesnt exist locally in that function
:)
#7
11/21/2006 (6:57 am)
Alright, got it half working...

Using this code, my player respawns when he enters the trigger. The only problem is that I never killed the old player; so a new player spawns, but the old player is still sitting in the trigger...

function SpawnTrigger::onEnterTrigger( %this, %trigger, %obj )
{
echo( "The player has entered the trigger");

// This method is called whenever an object enters the %trigger
// area, the object is passed as %obj. The default onEnterTrigger
// method (in the C++ code) invokes the ::onTrigger(%trigger,1) method on
// every object (whatever it's type) in the same group as the trigger.
Parent::onEnterTrigger( %this, %trigger, %obj );

%obj.client.spawnPlayer();
}


How do I kill off the old player before the new one spawns?
#8
11/21/2006 (7:57 am)
Try out the code i suggested -
it simply teleports the player instead of creating a new one and having to delete the old one.
#9
11/21/2006 (8:17 am)
Thats awesome Orion, works like a charm..

Got halfway with the other method and didn't even try yours...

Thanks!