Camera Movement

Hey guys,

I’m trying to make my main camera snap to a position of an empty gameobject by a press of a button, for about five seconds then return to its normal target (player) Please and Thank you :wink: a code snippet in C# would be much appreciated!

Something like this might help:

using UnityEngine;
using System.Collections;

public class CameraMove : MonoBehaviour
{
	private Vector3 _initialPosition;
	private Vector3 _targetPosition;
	private bool _inTargetPosition;
	
	void Update()
	{
		if(Input.GetKeyDown(KeyCode.Space) && !_inTargetPosition)
			StartCoroutine("MoveCamera");
	}

	IEnumerator MoveCamera()
	{
		_inTargetPosition = true;
		transform.position = _targetPosition;
		yield return new WaitForSeconds(5);
		transform.position = _initialiPosition;
		_inTargetPosition = false;
	}
}