How to make enemy ped squad (follow and protect their leader)
-
I want to spawn a group of peds that is in some sort of a "squad" together - where if someone in their squad gets attack, all of them will retaliate. They will also have a leader of some sort, where I can issue a task to that ped, and the rest of the squad follows him. Here's what I wrote so far:
List<Ped> alltargetpeds = new List<Ped>(); PedGroup enemyGroup = new PedGroup(); // Set Location Vector3 pedspawn = World.GetNextPositionOnStreet(Game.Player.Character.Position.Around(10f), true); // Spawn Peds for (int i = 0; i < totalpeds; i++) { Ped targetped = World.CreatePed(new Model(PedHash.FibMugger01), pedspawn); targetped.Weapons.Give(WeaponHash.SMG, 99999, true, true); targetped.AddBlip(); targetped.CurrentBlip.Color = BlipColor.Red; alltargetpeds.Add(targetped); } Wait(1000); foreach (var ped in alltargetpeds) { Function.Call(Hash.SET_PED_AS_GROUP_MEMBER, ped, enemyGroup); } Function.Call(Hash.SET_PED_AS_GROUP_LEADER, alltargetpeds[0], enemyGroup);
The enemies spawn, however they're just standing there doing nothing. When I punch one member of them, the rest just continue standing and not defending their group member. When I issue their leader to "wander around", they don't follow him either. I'm quite confused.