you could use 2 vars for the result to determine the target:


var index=-1, highest = 0

for(iterate throu respawnpoints-array)
{
if(vec_dist(player2.x, respawnpoints[i])>highest)
{
index = i
highest = vec_dist(player2.x, respawnpoints[i])
}
}

if(index>=0)
{
most_far_respawnpoint = respawnpoints[index]
}


hopfels idea is good if you dont want to have fixed respawn points.
after calculating the respawn point, you can re-create or re-translate the player to this position and adjust the camera using the player´s coordinates.
but beware: if you have a non planar bottom or a more complex level (like a multi-floor building) you should calculate also the z-coordinate (by using c_trace from the random-generated-z-value to the ground). but i would use (many) fixed respawn points instead a free random position, because if you choose the random-values wrong, your player could respawn at a bad position (like outside the level)

Quote:

So when a player dies should it respaw in one of those two cases.

disagree. he will respawn everytime at vector(800,800,0) and sometimes on more places

Last edited by Tempelbauer; 12/05/10 20:08.