Using "+" operator with Float type variables in Vector3?

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…

mainCamera.transform.position = new Vector3(_pc.transform.position.x, _pc.transform.position.y + yOffset, _pc.transform.position.z + zOffset);

You forgot “.z”

you’re missing the .z here:

_pc.transform.position + zOffset

should be…

_pc.transform.position.z + zOffset

Oh, how I can forgot it. Well, actually I didn’t forgot, I thought that it wasn’t put “.z” at the tutorial too. I am newbie. :smile: Thanks to you two for your help.