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