- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
phoenix25 · Mar 03, 2014 at 02:52 AM ·
sidescrollergame over
C# Script help with 2D sidescroller
How do I edit my script in order for the player to respawn to (0,0,0) when it reaches the Y coordinate of (0,-10,0)? My C# script is as follows:
using UnityEngine;
using System.Collections;
public class GameManager : MonoBehaviour {
public GameObject player;
private GameCamera cam;
void Start () {
cam = GetComponent<GameCamera>();
SpawnPlayer();
}
// Spawn player
private void SpawnPlayer() {
cam.SetTarget ((Instantiate (player, Vector3.zero, Quaternion.identity) as GameObject).transform);
}
}
Comment
Answer by highpockets · Mar 03, 2014 at 07:25 AM
void Update()
{
If( player.transform.position.y <= -10 )
{
player.transform.position = Vector3.zero;
}
}
I'm getting an error message that reads, "All compiler errors have to be fixed before you can enter playmode" the bottom is saying "error CS1525: Unexpected symbol '{'". Am I adding this to my script from above? if so, where do I add it?