At the beginning of the scene, 5 spawn points for ammunition are created inside the game arena.
After that a timer starts and every 10 seconds an ammo box is created at one of the spawn points
Now I’d like to add a power-up that creates an ammo crate for each free spawn point without overlapping other crates if there are any in the game.
Can anyone help me?
If you use an inverted collision condition between your spawn point object and the spawn object or object group, it will only pick the spawn locations without a spawn object. Make sure the spawn location is first in the condition.
I hadn’t thought of that, it was so simple… One last question: when the powerup is activated, the tween effect is activated on crates that collide with spawnpoints.
How can I cancel it on crates that are already on the ground?
I meant that the crate at the spawn point is also triggered by the tween and therefore pushed away.
I don’t understand why the tween is still triggered if it isn’t created.
Which events are triggering the tween. Maybe you can use the same collision event. Inverting a collision condition can be tricky. Sometimes, it helps to put it inside a for each object. Other times, you need to use a regular collision inside a NOT condition. The order of the objects sometimes also matter.
Please help me, I’ve been trying for days without success.
These are all the events:
At the beginning of the scene, spawn points are created where ammunition is dropped.
a timer is activated which I set every 10 seconds for testing where it chooses one of the spawn points and creates a crate at -200 y activating an interpolation towards the spawn point simulating the fall from the sky
The timer is cleared after the fall and then reactivated once the crate is opened
What I’d like to do is create a power-up that generates ammo at all five spawn points, provided there isn’t already a spawn point occupied.
What I can’t figure out is how to ignore the interpolation if a crate is already at the spawn point, and how to avoid overlapping the free spawn points if there are still crates to open but the power-up is deactivated and the timer is reset.
this is what i currently have but it is wrong:
You probably don’t need the trigger once especially if there could be multiple objects in collision at the same time bc it would prevent the other objects from being triggered.
Check the variable
Add a subevent of a for each object
Put the other actions in it or as a subevent.
This line might be continously resetting the timer unless the object is deleted or the animation is changed. IDK the whole process.
I don’t have the right now to really look it over but thats what jumped out at me.
If it’s a matter of not filling the occupied zones then check the collision between the swawn point and chest. Using an inverted collision. That will will filter out the spawn points in collision with an object, then you could use a subevent of for each spawn point with the remaining spawn points and create a random box for each point then reset the timer or delete the timer and restart it when the chests are opened.
I had already tried to invert the collision but it doesn’t work… in addition to the problem of filling the spaces I have the problem of the tween being applied to all the boxes, consequently they are pushed out of the spawn points
If the crates are pushed away with a tween then maybe you could spawn the object to a position above the spawn point and then tween it to the spawn point.
Another option would be to enlarge the spawn point object. That way if you move the crate, it would still be in collision with the spawn zone.
Another option is to use an object boolean like spawned. Set it to true when an object is spawned and then set it back to false when the crate is deleted.
I used object linking and because I’m on my phone, I used a delete zone object to trigger the deletion.
A larger zone might be easier. You would spawn the object to the center X and Y.
Also, the zone might need a cool down timer so it doesn’t just spawn a new crate the second the old crate is deleted. Or maybe, you could check if the player was close to a spawn point.