0
Answered

Player respawn.

Pandar 9 months ago in Game Creator updated by Marti (Lead Developer) 9 months ago 3

Hey. In one of my old projects, the character revival was implemented in this way. The first script declared a variable:

public static class GameVariables

{

public static Vector3 checkpoint;

}

The second script hung on the object in the scene:

public class Checkpoint : MonoBehaviour

{

void OnTriggerEnter(Collider collider)

{

if (collider.tag == "Player")

{

GameVariables.checkpoint = transform.position;

}


And the third script on the character:

public class FallDetect : MonoBehaviour

{

void Start ()

{

GameVariables.checkpoint = new Vector3(3, 6, -14);

}

void Update ()

{

if (transform.position.y < -12)

{

transform.position = GameVariables.checkpoint;

}


The character appears in a certain place, and if it falls below the -12 on the Y axis, it is reborn on the checkpoint. Now, in the GC, this does not work, for some reason)). And I'm not a programmer. Please tell me how to implement this system in the GC.

Unity version:
Game Creator version:
Declined

Hi Pandar;

Probably because you haven't marked the Player object with the Player tag. Despite this, there is not a trace of Game Creator code, so we can't really provide support for this.

Hi. I published the code in order to make it clearer what I need. How it worked before. And the question was - how to do this with GC? At least in general terms...

Answered

Oh I see. It shouldn't be difficult. Basically you will need to create a very big Box Collider object that covers all the lower ground of your level. Then, add a Trigger "On Player Enter". This will execute a set of Actions every time the player touches this collider, which should only happen when the player is falling to his death.

Then, for the Actions, simply use the Teleport action. This will make the player spawn at a specific position. You can either use a position or use a Marker as the checkpoint destination.