Help with coroutines

I’m trying to write a coroutine that can keep a camera in place for 4 seconds after the player dies and then move back to the player at the respawn point, at the moment the camera goes back to the respawn point immediately upon the death of the character and the player can’t see how they died.

I tried using invoke and unity just produced 1000s of player characters that kept on respawning and dying over and over again. so now I’m back on coroutines.

This is what I’m trying to do:

if deathparticles is called

IEnumerator CameraWait()
yield return new WaitForSeconds (4);

Debug.Log (“I’m waiting”);

transform.position = Player.transform.position + offset;

startCoroutine (CameraWait ());

Hi! If you still having truoble with it,
Then next script attachet to Camera works 100% special test was done righ now.
Based on script by @Mavina, but I`ve changed z position of camera transform couse test was on 2D scene. Here script:


Don`t forget to attach it to your camera.
And for additional thing? package from unity with wich I was testing this script. Uses only some blocks and robot from 2D standart assets and only one scene - test =)
Hope it will help you.

Tried to pack unity package to fit here but got nothing.
Putting it into the cloud if you`ll be interested in it.
Folder: Camera spawn example
Sorry for script it attachement. Many times tried to write it normally here but in the end there were thome thing of %%%—534963 etc. and only some pieces of code.
DNK why that happend.
Glad if helped in anything.