How to make Riggged character visible with trigger?
So there is path which the player walks down, at a certain point there is an invisible plane that is a trigger. When the player collides with the trigger, the enemy character becomes visible behind him and activates a script that has the enemy follow the player.
I had this so far :
var Zombie : GameObject; var trigger = false;
function Start () {
trigger = false;
Zombie.GetComponent.<Renderer>().enabled = false;
}
function OnTriggerEnter (other : Collider) {
trigger = true;
}
function Update () {
if (trigger == true) {
Zombie.GetComponent.<Renderer>().enabled = true;
}
}
I didn't realize that the character rig I was working with was just a folder containing subfolders which contained the individual pieces of the whole character e.g. head, neck, spine.... and each has its own mesh renderer. Please explain to me a way to make this possible, (and if you have the time, how to also activate the follow script on trigger)
Thanks!
first off, looking at the " OnTriggerEnter ( other : Collider ) " part.
you have to define other.
e.g. OnTriggerEnter (other : Collider){ if(other.tag == "Player"){ //code here; } }
if you're player has a tag, add it to the if statement
that may be the problem.
Answer by fahimalavi · Jan 14, 2017 at 10:52 AM
First of all if I would be you then I would make life easy, spawn a zombie prefab using Instantiate instead of making it visible using rendering tag. When you instantiate your character Start method will be called, use this method to follow the player.
Regarding your mesh hierarchy, it depends how you have made your mesh in maya or any other similar software. , it will be visible in same way. If I would be you I would import maya .mb file directly into unity3d like I did in RabbitBinkies.
Your answer
Follow this Question
Related Questions
unfortunatelt,App) has stoped working 1 Answer
If statement is always true 2 Answers
Code error :/ 1 Answer
Need help with code. Issue CS0131,Having troubles cs0131 2 Answers
code error how i fix this?,how i fix this coding error? 0 Answers