- Home /
Collision, change skybox in game
I need a script that allows the skybox to change after my first person controller collides with an object. I've tried this javascript function OnTriggerEnter(other : Collider) { if (other.tag == "Player" && RenderSettings.skybox != otherSkybox) RenderSettings.skybox = otherSkybox; } However, I do not know what to put in 'otherSkybox', what identifier to put. Let's say my skybox is called xxx in the assets folder, how do I apply it in this code? Or are there any other simple codes that allow collision then skybox change in game?
Many thanks in advance
Answer by Subzero619 · Nov 02, 2014 at 01:15 PM
Right.
You going to need two objects, your player with the tag "Player" and a cube or something that has a collider on it.
Attach this script to the collider and it will work perfectly as I have tested it.
var Skybox1 : Material;
var otherSkyBox : Material;
function OnTriggerEnter(other : Collider){ //When the player enters the collider
if(other.tag == "Player"){ //Checking if it is the player
if(RenderSettings.skybox != otherSkyBox){ //if Skybox is not equal to the skybox we want
RenderSettings.skybox = otherSkyBox; //change it to that skybox
}
}
}
Your answer
Follow this Question
Related Questions
Script crashes Unity 1 Answer
Have script detect which collider 2 Answers
Decreasing Player Health On Collision with Enemy 2 Answers
IsTrigger problem 1 Answer
Object won't collide with Player unless Player is moving 1 Answer