Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Turn on Script when collide with this object?

$
0
0
I have a script attached to numerous NPCs and I want to send a message to turn on the script for ONLY the NPC that I have collided with and not anyone else. I don't want the 'NpcBattleScript' to turn on for every NPC that has 'npc' tag or has the script attached. I also want to turn off that script from within the script after it has finished doing a particular thing. Can anyone point me in the right direction? I know: if(hit.collider.gameObject.tag == "npc") { // in here I want to say, turn on NpcBattleScript } in the other script I want something like: if (battleOver = true) { //turn off this script }

Viewing all articles
Browse latest Browse all 171066

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>