- Home /
How to change a texture of a gameobject by collider trigger ?
Hi,
This is the situation. I have a third person character walking on a path. Whenever he walks trough a "pick up" I want the texture of the path to change.
I've tried this :
function OnTriggerEnter (other : Collider) {
renderer.material.mainTexture = "Asphalt";
}
But it doesn't work. Actually as you may have notices i'm quite new to scripting (A)
Can anyone help me out ?
Thanks,
Niels
Answer by Hei · Mar 06, 2011 at 12:54 AM
You can use this script...
var yourTexture : Texture;
function OnTriggerEnter (other : Collider) { renderer.material.mainTexture = yourTexture; }
I think it can help you.
Thanks for that script m8 !
It does get me a little further, but now it only changes the texture on the cube and not that of the path.
I want the cube where my character can walk trough to act as a trigger to change the texture of the path that it is walking on.
Your answer

Follow this Question
Related Questions
How to SetActive an object with a raycast? 2 Answers
OnTrigger Enter not working - Tried everything! 3 Answers
Can't click gameobject when over another trigger? 1 Answer
Fire Collision detection 1 Answer