I have a blueprint that is supposed to be spawning a predetermined amount of trees in random locations but not overlapping one another. It spawns trees but it usually spawns the wrong amount, and, using debug sphere trace it is doing more work than it should be.
I’ll try to explain each screen shot as good as I can.
This event is supposed to get a random location and run a sphere trace to make sure the space isn’t occupied. If the area is occupied then it just tries again (that part is unfinished). If the area is clear then it places a tree.
I set the number of trees to 1 so the main loop should run until it spawns a single tree and then stops. I ran it three times in a row and these were the results.
As you can see it places between 1-4 trees AND you can see that there were sphere traces that came back empty which SHOULD mean it places a tree there.
What the fudge is going on here?!?
I’m glad you were able to solve that last problem so quickly but I still am getting one minor issue.
It still runs multiple sphere traces that do not spawn trees. Every sphere trace that comes back negative should spawn a tree but some do not, any idea why?
i have never used instance static mesh component but from a quick look at it it seems you would have 1 instanced static mesh component which you keep calling “add instance” on to add more instances of the mesh so i don’t really understand why you have an array and are getting the Nth element of it
in short, i don’t know, but that is where i suspect the problem is.
"Add an instance to this component. Transform is given in local space of this component. "
local space of this component.
your sphere trace is in world space and then you’re plugging that same location straight in to the instanced static mesh component which does things in local space. perhaps subtract the location of the actor from “current location” before plugging it in to add instance?
altho if this is the issue idk how it ever worked at all. probably your actor is at 0,0,0 so it makes no difference in this case
chuck a bunch of print strings everywhere ie. after the branch conditions after the sphere trace so you can get a clearer picture of what is happening. aside from that i’m out of ideas.