randomly spawing yet destroyed actor
aa233
Member Posts: 8
Hi all,
I have one more minor speed-bump in the way of my first completed game on here. I was wondering how it would be possible to make a collectible item that randomly spawns somewhere else after it is destroyed. I followed the "how to make a collectible item like a coin" tutorial and that seemed to work, but i can't figure out how to make the item re appear somewhere else to be collected once again. Maybe an integer would work for this? And if the value is 0 then another actor should spawn? I'm pretty new at this so any ideas are appreciated. Thanks!
I have one more minor speed-bump in the way of my first completed game on here. I was wondering how it would be possible to make a collectible item that randomly spawns somewhere else after it is destroyed. I followed the "how to make a collectible item like a coin" tutorial and that seemed to work, but i can't figure out how to make the item re appear somewhere else to be collected once again. Maybe an integer would work for this? And if the value is 0 then another actor should spawn? I'm pretty new at this so any ideas are appreciated. Thanks!
Comments
Create a global variable of either boolean or integer (true/false or 1/0) and once you display the item in the scene, set this global variable to true. Once the player collects the item, set it back to false. From there you can make a part of your logic to display the item again in the future to first reference the state of the variable.
For example, if your variable called 'isItemVisible' is currently false, then you can randomly place another item; otherwise you hold off.
Hope that helps.