Hello there! I’m trying to figure out how I would do this; I have my main camera (camera A)that I’ve set up to render depth only, and a second camera (Camera B) that I’m using to render the skybox in. What I want to do, is put Camera B inside a sphere (geometry) and render that sphere as the skybox for Camera A. It works fine, except that I need Camera B to rotate on identical axis as Camera A, or else the effect is lost. No translation, just the rotation. Any ideas? It seems simple enough in theory, but I haven’t got the slightest idea of where to start. Is there a way that I can call the rotation of Camera A (main camera) and update Camera B’s movement based on that?
You betcha. Attach a script like the following to Camera B, then in the inspector assign Camera A to the “target” variable.
public Transform target;
void Update () {
transform.rotation = target.rotation;
}
![]()
hmm
NewBehaviourScript.js(2,8): BCE0044: expecting function, found 'Transform'.
Are you using JavaScript? The script I posted was written in C#, which in JavaScript looks like:
var target : Transform;
function Update () {
transform.rotation = target.rotation;
}
No I’ve got it going in C# after a bit of realization, but it’s not rotating camera B according to camera A’s rotation. I defined camera A in the inspector. hmm
public class NewBehaviourScript : MonoBehaviour {
public Transform target;
void Start () {
}
void Update () {
transform.rotation = target.rotation;
}
}
Oh nevermind! It’s working and I was editing while previewing, therefore it didn’t keep my settings. (It’s been a long day)
Thanks so much for your help. I owe you a coffee! =D