- Home /
Player invisable cloak?
In my game I want the enemy(other team) to be able to turn invisable for a short amount of time, with a recharge time. So, how do I achieve this, is there a way to disable mesh render, or should I have it so the mesh for the player moves below the floor?
Answer by TheRichardGamer · Dec 15, 2013 at 08:32 PM
Well, you're going to be disabling the mesh renderer of the players, and to do that you will need to access the objects (players) with a script. Now I'm not going to make a complete script or anything, but I'm gonna give you an example so you'll get the idea.
I hope this helps.
var Player : GameObject;
var TimeEnabled : float; //this is the amount of seconds the players will be cloaked
var IsCloaked : boolean = false;
function Update () {
if(Input.GetKeyDown(KeyCode.C)){ //you may use any input here, this is just an example
if(IsCloaked == false){
Cloak();
}
}
}
function Cloak () {
Player.renderer.enabled = false;
IsCloaked = true;
yield WaitForSeconds(TimeEnabled);
Player.renderer.enabled = true;
IsCloaked = false;
}
Thanks, TheRichardGamer, your code works great. Just what I needed
Your answer
![](https://koobas.hobune.stream/wayback/20220613124235im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Skinned Mesh Count more or less better? 1 Answer
Human skin not getting exported from Maya to Unity 1 Answer
How to combine materials at runtime? 1 Answer
skinned mesh renderer, combine meshes can't see the result, what am I doing wrong/ missing? 0 Answers
Combining meshes in game without loosing boneWeights 0 Answers