Hello,
I recently watched This Video that shows how to make a spawn area for items.
It works which is good, multiple spawn although now I would like to program it so that every time the level is entered there location will change. Also I am placing AI in here instead of items and it seems that there is not that big of change
If someone could help, that would be great! thanks
I am already using a navmesh to let the AI move.
Do I use another navmesh?
Can you explain what you mean by get random points from the nav mesh and spawning from it? Because if you mean to add specific points then that’s not what I want as I want them to be able to spawn anywhere in an area and also spawn multiple.
the code used in the tutorial already uses random placement. so all you need to do is run the code at begin play rather than in the construction script. if it runs on begin play then it will get a random location each time the level loads instead of only on construct.
as for the using ai instead of items, you just need to use a spawn node instead of a add component. so use either spawn actor from class or theres also another node i don’t remember the exact name but its something like spawn ai into level. also make sure your characters (i assume character) is set to be possessed by a ai controller on placement and spawn.
Alright so I played around with it and added what you suggested.
Although instead of changing the location, it spawns random amounts between 4 and 6 (???)
random amounts huh. hmmm theres only two reasons i could think of that would result in something that looks like that. first would be if you were setting your variable to a random number. the other would be that your still using the relative location instead of world location and some just aren’t visible (ala spawning under the world or far from where you expect).
Although if I want to change it how would I? Because I am using a float (or something) I cannot simply implement the WorldLocation thing as the current code I have is not compatible
i believe the variable i was referring to was the number of cattle as shown in your picture.
Because I am using a float (or something) I cannot simply implement the WorldLocation thing as the current code I have is not compatible
that doesnt make a whole lot of sense. your not using a float anywhere in the screenshot sooooo.
the spawn nodes use world locations as does the random point in bounding box. try dragging off your spawn range and searching for get world location or use the actors location.
When I mess with my “number of cattle” variable, it increases the number of cattle by a lot (for some reason) I would implement 4 and 7 will spawn (???)
Also, I see, I was able to implement the world location from my spawn range.
from the look of things you are doing nested loops and thats why your getting large numbers. if i look at the picture you posted a few posts ago it shows you are using a loop on being play then calling the function, within the function you are using another loop. as an example if your number of cattle was 2, you would be running the first loop 3 times, each iteration of that loop would run the next loop 4 times (according to latest picture), the end result is that you would spawn 12 actors (3*4=12). so i would eliminate the loop in the function.
I was able to implement the world location from my spawn range
thats not shown in your picture. in the picture posted the world location isnt connected to anything so its not actually being used. connect the world location return value to the origin pin of the random point node