-
December 28, 2016 at 18:42 #17338
Hi i’m trying to figure out, with no luck, how to set a group of 4 AI Units to follow the player as a group, there is some tutorials on youtube, but my problem is that my player is 3rd person character controlled by the user. How do i set the units as a group whitout selecting them ? And how do i make them as group follow the Player character?
Also at first they will follow him as a disorganized group but in the future i intend to have them following the player in a formation, like shield wall or a triangle.
Att. Elias
December 28, 2016 at 22:24 #17340Ok, the grouping and formation part is ok, now only the follow left, i’ve tried to put the MoveTo(Player) on the Update Method but the Units stand still recalculating the path every frame i guess.
December 28, 2016 at 22:52 #17342Thought it was ok, out of nowhere i started to receive the following message:
NullReferenceException: Object reference not set to an instance of an object
Apex.Units.TransientGroup`1[T].PrepareForAction () (at Assets/Apex/Apex Path/Scripts/Units/TransientGroup.cs:399)Current code:
C#12345678910111213141516171819202122232425public class PlayerCharacterManager : MonoBehaviour{public PlayerCharacter playerCharacter;public PlayerUnit[] playerUnits;public Transform target;private DefaultSteeringTransientUnitGroup _playerGroup;public void Initialize(){_playerGroup = new DefaultSteeringTransientUnitGroup(5);playerCharacter.Initialize();foreach(PlayerUnit __playerUnit in playerUnits){_playerGroup.Add(__playerUnit.unitFacade);}_playerGroup.SetFormation(new Apex.Steering.FormationRow(3f));_playerGroup.MoveTo(target.position, false);}}- This reply was modified 2 years, 1 month ago by Elias Lessa.
December 28, 2016 at 23:04 #17345Ok, back again on track, it seems that Unity decided to call the Initialize of the script above before the Start of the PlayerUnit wich assing the unitFacade with GetUnitFacade();
Now, only missing a way to follow the player.
December 29, 2016 at 16:00 #17360December 29, 2016 at 18:36 #17380Thanks! it worked.
You must be logged in to reply to this topic.