Camera problem by switching between 2 player objects

I want to set the cameras I use to look in the same direction the old camera was watching but I can only get that on one object to work. Either the first or the second.
I´m building a Metroid Prime clone and i want to switch between first person and the Morphball.


using UnityEngine;
using System.Collections;

//Transformation back into first person
public class Morphball2 : MonoBehaviour {
	
	public GameObject Ball;
	public GameObject Player;



	
	// Update is called once per frame
	void Update () {

		
		if(Input.GetKeyDown(KeyCode.C)){
//create new first person player object
			GameObject g = (GameObject)Instantiate(Player, transform.position, Quaternion.Euler(0, Camera.main.transform.eulerAngles.y, 0));	
//delete Morphball object
			Destroy(Ball.gameObject);
		}
		
	}
}

With the above script the first person char looks into the same direction the Morphball camera looked. If I replace “Quaternion.Euler(0, Camera.main.transform.eulerAngles.y, 0)”
with “Player.transform.rotation” the first person char always looks at spawn to
(0.0,-1.0,0.0,0.0).


using UnityEngine;
using System.Collections;

//Transformation into Morphball
public class Morphball : MonoBehaviour {

	public GameObject Ball;
	public GameObject Player;



	
	// Update is called once per frame
	void Update () {
		
		if(Input.GetKeyDown(KeyCode.C)){

			GameObject g = (GameObject)Instantiate(Ball, transform.position,
			                                             transform.rotation);

//delete first person object
			Destroy(Player.gameObject);

		}

	
	}
}

But this script sets the camera transform.rotation on spawn always (0.0,1.0,0.0,0.0) no matter what I do except I replace
“Quaternion.Euler(0, Camera.main.transform.eulerAngles.y, 0)” from the first script with “Player.transform.rotation” then the Morphball looks inte the first person direction.

This is very confusing and frustrating please help me.

Greetings BurningSky

  • double-check real tranform’s rotation to be sure it is set wrong animation/move can be implemented without parent transofrm (which you use) rotation, so parent’s rotation is always identity.
  • never use euler angle component without other components. eulerangles.y can produce unpredictable results since it’s just a part of rotation sequence
  • to get ‘look-rotation’ use Unity - Scripting API: Quaternion.LookRotation

I activated the default Global Fog with a density of 0.2 as a surprising result there was no Global Fog but the deep water looked more realistic, at least in the editor mode. (I use the fog settings in combination with the Global Fog script to archieve an underwater look when you dive)