I am trying to make a game that spawns obstacles every second, but cannot figure out why it isn’t working. Here is what I have so far, its basically supposed to spawn a new object called ‘test’ every tick, and add it into my array ‘obstacles’. What am I doing wrong?
More to above you are looping through array which would contain object allready created. Are you creating them? If array is not initialized it does nothing.
And as Zeustiak written you need to use actual spawn function.
Spawn actor is going to be more resource intensive than Add Instance. Of course, adding instances on an Event Tick is probably going to end in disaster unless they are quickly removed.
Oh, now I notice something about the graph! Hi you need to set a Delay timer, not set deltatime. The set Deltatime did nothing actually. Thats not how t use it.
What you have it will try to create an instance every tick, not every sec!
After looking at a tutorial, I think Add StaticMeshComponent work as well, as long as its a staticMeshComponent (Obviously).
In any case, try add a timer, creating a object every tick will crush the program, or some very bad slowdown. Maybe that’s the problem. Also you should have a limit on array size.
Also I think for ‘For each’ loop to work, the array must be at first filled with values.
If the array have a size of Zero, then I think it will not run the next execution, which may explain why it it not work.
Try instead using add & put this in last step of the node. (see the screenshot from Tom Looman Tutorial)
My suggestion to you is to do it step by step. Start simple. At first make sure you can spawn an object by a key press, Then make sure it can be stored in an array, slowly moving into the final solution you wanted.
Hey guys thanks for the help! You helped me find my mistakes and now I got the map randomly generating, now I just need to learn how to do dynamic arrays in blueprints Is this possible?