- Home /
In Space Shooter game, I want my spaceship to get highlighted when user touches it.
Highlighted mean the spaceship should be upheld when touched.
Answer by RadonRaph · Oct 09, 2019 at 10:37 AM
Hello @bhardwajashish9717 you can do this by multiple ways:
1.Create an animation with animator that change the color of the sprite renderer (if you working in 2D). 2.Change the color of the sprite renderer with code thanks to a coroutine: https://docs.unity3d.com/Manual/Coroutines.html It will look like this: void OnHit(){ StartCoroutine(highlight()); }
IEnumerator highlight(){
getComponent<SpriteRenderer>().color = Color.red;
yield return new WaitForSeconds(0.2f);
getComponent<SpriteRenderer>().color = Color.white;
}
If you are working in 3D you can use the coroutine to change the material or make a custom shader. Hope that will help. Raph
Your answer
Follow this Question
Related Questions
Paint 3d export fbx file does not work 1 Answer
what's the problem? (ninja.js) 0 Answers
I can not import the .exr file into my project 0 Answers
How to center a rect in a gui.label 1 Answer