Gmate 3 Posted September 6, 2021 Hey, I'm new to coding and mission editing in Arma, so please go easy on me. I'm attempting to create a template of sorts to build future missions out of, I want to have a clean, easy & modular spawn system that can be easily tweaked for different scenarios, I also want to do this without mods. I am aware of 2 main ways of handling spawning AI, "createUnit" and "BIS_fnc_spawnGroup" I'm not exactly sure what is best for my specific use case, and I'm not entirely sure how to use either of them properly. Essentially what i want to do is have a trigger spawn multiple units of my choice on a marker and then have the units move towards another marker, I also want to be able to modify the behavior of these units (ex. start on limited speed.) I have tried a few different methods to achieve this, these are the issues I'm having with each: With "createUnit" the only way i have found to spawn multiple units is to repeat the code over and over, I'm sure there's a better way to do this and if so I'd love to know. Also with my current setup i have to repeat the domove code for each individual unit, I would also like to know if there is a better way to do this. Here is the code located in the triggers "On activation" field: Spoiler spawn_group_1 = creategroup west; enemy_1 = spawn_group_1 createunit ["B_Soldier_F", getmarkerpos "spawn_point_1" ,[],0,"form"]; enemy_2 = spawn_group_1 createunit ["B_Soldier_F", getmarkerpos "spawn_point_1" ,[],0,"form"]; enemy_1 domove (getmarkerpos "spawn_order_1"); enemy_2 domove (getmarkerpos "spawn_order_1"); With "BIS_fnc_spawnGroup" I'm not entirely sure how to order the units spawned within to move towards a marker, I would like to know how to do this, and I also read somewhere that the group will not be automatically deleted when all units are dead so I added a line at the end, I have no idea if it works though. Here's the code for that from the triggers activation field: Spoiler _spawn_group_2 = [getmarkerpos "spawn_point_2", west, [ "B_Soldier_F", "B_Soldier_F" ] ,[],[],[],[],[],180] call BIS_fnc_spawnGroup; spawn_group_2 deleteGroupWhenEmpty delete; I read that createUnit is better for performance when paired with the sleep command, however i have no idea how that works, and I also have my doubts, at-least with my current code repeating the same lines over and over for each unit seems very inefficient, the BIS command seems much cleaner however i don't know how to issue a move order with it which is my main problem. Additionally i would like to setup a headless client but that's a whole different topic and I don't want to draw this out any further, though if you feel like you have some useful advice on that please do share. Thanks and any advice & methods is appreciated. ❤️ Share this post Link to post Share on other sites
Enigx 39 Posted September 6, 2021 Hi, as already posted in a previous post, check this script I did time ago. It could be useful for your scope. Share this post Link to post Share on other sites
Gmate 3 Posted September 6, 2021 12 minutes ago, Enigx said: Hi, as already posted in a previous post, check this script I did time ago. It could be useful for your scope. Thank you for that, that is a very useful script and I may use it however I would rather make my own if I can if i can figure it out. Share this post Link to post Share on other sites
Gunter Severloh 4034 Posted September 6, 2021 Hi Gmate, in the same subforum your post here is in, there is a pinned thread titled - AI Compilation List if you haven't seen it already, it has a large section of threads and scripts for spawning AI if you need some additional information on AI spawn, see the thread here The AI spawn and respawn thread section may have many various ways of setting up in the editor and how to code it accordingly, or you can go to the script section and find a script that best suites your needs. Hope that helps! Cheers! 2 Share this post Link to post Share on other sites
pierremgi 4829 Posted September 6, 2021 7 hours ago, Gmate said: I have tried a few different methods to achieve this, these are the issues I'm having with each: With "createUnit" the only way i have found to spawn multiple units is to repeat the code over and over, I'm sure there's a better way to do this and if so I'd love to know. Also with my current setup i have to repeat the domove code for each individual unit, I would also like to know if there is a better way to do this. Here is the code located in the triggers "On activation" field: With "BIS_fnc_spawnGroup" I'm not entirely sure how to order the units spawned within to move towards a marker, I would like to know how to do this, and I also read somewhere that the group will not be automatically deleted when all units are dead so I added a line at the end, I have no idea if it works though. Here's the code for that from the triggers activation field: I read that createUnit is better for performance when paired with the sleep command, however i have no idea how that works, and I also have my doubts, at-least with my current code repeating the same lines over and over for each unit seems very inefficient, the BIS command seems much cleaner however i don't know how to issue a move order with it which is my main problem. Additionally i would like to setup a headless client but that's a whole different topic and I don't want to draw this out any further, though if you feel like you have some useful advice on that please do share. Thanks and any advice & methods is appreciated. ❤️ Both methods are available: I often used BIS_fnc_spawnGroup as quick and dirty way to spawn any units, referring to config groups or using the array for customized ones. The limit is that you can't spawn vehicles in towns. They collide, blow and bounce into the air. the createUnit is a little bit longer to write but it's handy for customizing unit per unit and tweaking their position. There is no real difference about resource, so, that depends on how high you set the bar for the results. I finally made a module (two in fact) spawning very customizable units/groups (even backpack/crate contents) using createUnit and advanced function for positioning. So, createUnit + createVehicle are less immediate than BIS function but you can script as you wish on this base. 1 Share this post Link to post Share on other sites
Gmate 3 Posted September 7, 2021 Thank you both. I did have a look at that thread already Gunter, it's honestly a great resource, there was so much there that I didn't read it all the way through but I will have a more thorough look and see if there's anything there that can help me, which I'm sure there will be. And pierremgi, it's good to know there's not much performance difference, i did benchmark it myself on a small scale just to see if there was any noticeable difference and you seem to be right, I did not notice any difference between the two methods resource wise. Share this post Link to post Share on other sites
pierremgi 4829 Posted September 7, 2021 20 minutes ago, Gmate said: i did benchmark it myself on a small scale just to see if there was any noticeable difference and you seem to be right, I did not notice any difference between the two methods resource wise. Yes, but that depends on what you want to spawn/where. For examples, spawning units on VR map, or tanks on Kavala (Altis main town) or even CAM LAO NAM (SOG Prairie fire), will be different if you are tuning the place they can spawn. In last case, forget bis_fnc_spawnGroup. It's a waste of code for a bad result (units stuck inside rocks, tanks blowing on obstacles/houses/walls) To make it short, the more complex vehicles/environment, the more resource demanding, up to the point you really need to script for that. Creating some units/assets is nothing in regard of placing them. See isFlatEmpty findEmptyPosition, and selectBestPlaces (I never used). Bis_fnc_findSafePos is not too bad, but you can adapt the commands (isFlatEmpty & finEmptyPosition) for more immediate result. Share this post Link to post Share on other sites