Hello all. I’m following a tutorial series but I stuck at somewhere. I have a question. I will first give the whole code:
using UnityEngine;
using System.Collections;
public class GameMaster : MonoBehaviour {
public GameObject playerCharacter;
public Camera mainCamera;
public float zOffset;
public float yOffset;
public float xRotOffset;
private GameObject _pc;
// Use this for initialization
void Start () {
_pc = Instantiate(playerCharacter, Vector3.zero, Quaternion.identity) as GameObject;
zOffset = -2.5f;
yOffset = 2.5f;
xRotOffset = 22.5f;
mainCamera.transform.position = new Vector3(_pc.transform.position.x, _pc.transform.position.y + yOffset, _pc.transform.position + zOffset);
mainCamera.transform.Rotate(xRotOffset, 0, 0);
}
// Update is called once per frame
void Update () {
}
}
When I try to compile this code in Unity, it gives error on this line:
mainCamera.transform.position = new Vector3(_pc.transform.position.x, _pc.transform.position.y + yOffset, _pc.transform.position + zOffset);
It says:
error CS0019: Operator `+' cannot be applied to operands of type `UnityEngine.Vector3' and `float'
How can I solve the problem? Thanks so much for your help…