Hi guys, having an issue getting this to work.
I have the player select a ship, which assigns them an Int, using the Int, I initiate into the ‘Game’ screen their ship through the Gamemanager, this screen doesn’t have a Camera, as I want it to be linked to the player, and only focus on them, so the PlayerPrefab has the Camera script, however, it doesn’t work, what am I doing wrong, I’m stumped…
Inst’d Code
using UnityEngine;
using System.Collections;
public class PlayerInstantiateScript : MonoBehaviour {
//Instatiate based on which bool.
public GameObject PlayerRocket1;
public GameObject PlayerRocket2;
public GameObject PlayerRocket3;
// Use this for initialization
void Start () {
if (ChangeShipName.ShipChoice==1)
{
Instantiate(PlayerRocket1, new Vector3(531, 59, 0), Quaternion.Euler(270, 0, 0));
}
else
if (ChangeShipName.ShipChoice==2)
{
Instantiate(PlayerRocket2, new Vector3(531, 59, 0), Quaternion.Euler(270, 0, 0));
}
else
if (ChangeShipName.ShipChoice==3)
{
Instantiate(PlayerRocket3, new Vector3(531, 59, 0), Quaternion.Euler(270, 0, 0));
}
}
// Update is called once per frame
void Update () {
}
}
Camera Code
using UnityEngine;
using System.Collections;
public class CameraStalkPlayer : MonoBehaviour {
public Transform player;
public Vector3 offset;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.position = new Vector3 (player.position.x + offset.x, player.position.y + offset.y, offset.z); // Camera follows the player with specified offset position
}
}