Hello,
I am using two factories to spawn two different types of objects.
I spawn over a hundred of object1 and object2 which both have collision boxes and add them to a table.
Then I immediately raycast from the position of object1 to detect if it is right next to any of object2.
The raycasts will always return no result and I’m guessing that its because the collision boxes or the gameobjects aren’t really there yet by the time I run the raycast.
So to test this, I run the raycasts function with a timer delay to wait a frame like this
timer.delay(0, false, function() RaycastAll() end)
This only works for a couple of objects to initialize and the raycasts to produce a result.
So then I upped the timer delay to 0.1 second and it works for all of the raycasts to produce correct results.
I think this must not be a good way to handle this problem because:
#1 I’m running from a nice gaming computer and if somebody runs my game from a old phone it might take them a lot longer to initialize and they would fail again.
#2 I’m guessing if I up the objects to 1000s instead of 100s then I would need to keep increasing the delay.
So my question is how am I supposed to properly wait for the gameobjects to full initialize on any device without putting in some arbitrary delay number? Or it could be possible that I am misinterpreting what the problem really is.
#firstpost, Loving Defold, I’ve been here a week trying to port my game in progress to this engine