Going to place this up as I work on this and a couple more scripts today. I’m working on my spawn checkpoint system which allows you to go forward with the checkpoints but not backwards. Basically if I climb 250 feet (activate the spawn point), and fall down to 150, I can’t reactivate the spawnpoints at 150 and 200 feet.
The Lerpz spawn point that I grabbed isn’t working as intended, where it not only causes problems with my camera, but if I have more than one spawn point my game starts getting confused as to which spawn point to send me to (two spawn points, I “Activate” A clone, AKA #2, and it will SOMETIMES go to #2 and sometimes go to #1, no error was shown in the debug log during the initial testing of the points.
So what I’m checking for, is a system where when I hit checkpoint #1, I spawn at Checkpoint #1 when I die, if I hit #2, I cannot reactivate #1 and spawn at #2.
Respawn script from Lerpz tutorial, stripped of the particle effects:
/*
Respawn: Allows players to respawn to this point in the level, effectively saving their progress.
The Respawn object has three main states and one interim state: Inactive, Active and Respawn, plus Triggered.
- Inactive: Player hasn't reached this point and the player will not respawn here.
- Active: Player has touched this respawn point, so the player will respawn here.
- Respawn: Player is respawning at this respawn point.
Each state has its own visual effect(s).
Respawn objects also require a simple collider, so the player can activate them. The collider is set as a trigger.
*/
var initialRespawn : Respawn; // set this to the initial respawn point for the level.
var RespawnState = 0;
// Sound effects:
var SFXPlayerRespawn: AudioClip;
var SFXVolume: float; // volume for one-shot sounds.
// The currently active respawn point. Static, so all instances of this script will share this variable.
static var currentRespawn : Respawn;
function Start()
{
RespawnState = 0;
currentRespawn = initialRespawn;
}
function OnTriggerEnter()
{
if (currentRespawn != this) // make sure we're not respawning or re-activating an already active pad!
{
// turn the old respawn point off
// Set the current respawn point to be us and make it visible.
currentRespawn = this;
}
}
What I’m looking at:
PSUEDOCODE
static var currentspawn : Checkpoint;
var thisCheckpointsPosition //If it's the first spawn point, second, third, it can be dependant on height
var Locked; //If it's locked it can no longer be activated.
function OnTriggerEnter()
{
if (locked == false)
{
//Make this the active spawn point
currentspawn = this;
//Lock it off from being reactivated
locked = true;
}
}
I actually don’t know how I should go at the code, because I could use the locking method, but then if I skipped a checkpoint I might accidentally activate a checkpoint I missed earlier and have to run farther than I need to (missed 200 ft checkpoint, Hit the 150ft and 250ft checkpoints, if I hit the 200ft checkpoint now, I’ll have to go 100 feet instead of 50 feet to the next checkpoint… for example’s sake)
AND DON’T DIRECT ME TO PLAYERPREFS…
I got that last time and it provided absolutely no help to my level screen problem. I’m not saving the game, I’m not switching screens, I’m just telling my game where to send the player after the player dies. And to also tell the spawn points not to work if I hit one farther than where the player currently is.
EDIT: After re-testing the first script from Lerpz, they now work correctly (must’ve been the Unity 3 update or something), BUT I still need the checkpoints to check if they’re a farther point than the last touched spawn point.