Can someone help me with locating my current character for ai follow script?

Updated on December 7, 2018 in  [R] Scripts
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
0 on December 7, 2018

Hey all, I have a script that switches character control between a team of four with the space bar, and I want all the other characters to follow the selected character. I made a script for the ai follow, but I need to reference the character switch script to find the current character. I’ve tried GetComponent with the character switch script, that didn’t work and the only thing that doesn’t crash my ai follow script is this piece of code, which doesn’t work:

ally = GameObject.FindGameObjectWithTag("Character").transform;

The reference from the character switch script that I need is: 

currentCharacter = characters[charactersIndex];

I’m using c# and I just need to know the correct line of code to use. Thanks in advance!

  • Liked by
Reply