help with checkpoint sytem C#

trying to instantiate an my player when the level starts at a object location this is and when i hit the checkpoint it moves the spawnpoint location so if the player dies i can hit gameover screen then loop round to checkpoint instead of starting again i know i could just create a new scene but would bulk out the project to much

so i thought if i spawn player at start of level at an empty gameobject spawn point then when the checkpoint is hit it moves the spawnpoint to new location then when the level resets the player spawns there heres what ive got so far any help would be great

using UnityEngine;
using System.Collections;

public class Checkpoint : MonoBehaviour {

public GameObject CheckP;
public Vector3 CheckPos;
public GameObject player;
public Transform SpawnPosition;
public GameObject SpawnPoint;

void awake(){

	DontDestroyOnLoad(SpawnPoint);

	}
void start(){

			Instantiate (player,SpawnPosition,Quaternion.identity);
	}

i need way to move spawn ontrigger and a way to make the transform a vector 3 thnx

void OnTriggerEnter2D (Collider2D other)
{

	if (other.tag == "Player")
		Instantiate(CheckP, CheckPos, Quaternion.identity);
		Debug.Log ("hit");
		

}

}
i need a way to transform the spawnpoint on trigger and a way to make the spawn position transform a vector 3 ive tried the unity docs but it want numbers for public vector 3 and transform is not accepted in the instantiate :stuck_out_tongue:

If, your game is 2D, then use Vector2.

1- Create empty gameobject name it — SpawnPoint
2- Create another gameObject name in — CheckPoint

Add this Script to CheckPoint :

using UnityEngine;
using System.Collections;

public class CheckPointScript : MonoBehaviour 
{
	public Transform SpawnPoint;

	void OnTriggerEnter2D(Collider2D col) 
	{
		if(col.tag =="Respawn")
			
		{
			SpawnPoint.position = new Vector3(transform.position.x, transform.position.y, SpawnPoint.position.z);

		}

	
		
		
	}
}

3- Add Box Collider 2D to CheckPoint with Is Trigger.

I hope this will help you :slight_smile: