- Home /
How to Activate texture on collison
Hi i am making a simple game where i want my GameObject to have the default material and i want to activate the texture material on collision with another GameObject
can anyone help me with a simple c# script
Answer by Fluffy_Kaeloky · Aug 16, 2016 at 03:11 PM
You can use Material.SetTexture(...) https://docs.unity3d.com/ScriptReference/Material.SetTexture.html
To get a reference to the material : https://docs.unity3d.com/ScriptReference/Renderer-material.html
To get the reference to a component : https://docs.unity3d.com/ScriptReference/GameObject.GetComponent.html
And upon collision : https://docs.unity3d.com/ScriptReference/Collider.OnCollisionEnter.html https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnTriggerEnter.html
Always remember to check Unity's documentation, 80% of the time the answer is right in front of you ;)
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
how to keep track of Lean Tween function? 0 Answers
Mirror : How to Sync child objects active status on join? 0 Answers
help with scripting combo 2 Answers