Depending how you item class is designed. If you got pick up and inventory item seperate you can do what write, if single class is used for pickup and inventory, you can spawn new item in place of pick up and hide component (by some call on pickup) until specific time pass.
I’ve got my pickups working well in blueprints, however I’m unsure about the best way to spawn them. I’ve been trying to make a class that spawns pickups at the start of the game and when they’ve been collected a wait time occurs before they next spawn again. (sort of like an MMO’s spawn time).
I was thinking that it would be like respawning a player, but I remembered players require pawns and playercontrollers. Has anyone achieved respawning pickups?
PS: This is for a local splitscreen multiplayer game.
What i would do if i was you: When the player collects de item i put a “DO ONCE”, hid the pickup mesh and do what the pickup do to player when is collected…then put a delay to respawn…after this show the hidden mesh and reset de DO ONCE…
I’ve recently implemented a system that does exactly what you want, I think.
I have a pickupSpawner blueprint class that has two variables: respawnTime (float) and pickupClass ( class [not instance] that inherits from my Pickup blueprint class. On beginplay, the pickup spawner spawns an actor of the pickupClass type. When the pickup is collected by the player, it triggers a custom event in the pickupSpawner that spawned it, which lets the spawned know that the pickup has been collected. The pickupSpawner then respawns the pickup after a delay specified by the respawnTime parameter.
One other addition that I’ve also implemented is a counter, which checks to see if the pickupSpawner has “stock” of the pickup before spawning. Each time the pickup is spawned, the counter is decremented, and once the counter reaches zero, spawning is prohibited
Hi Kagamusha,
I just so happen to be working on this for a personal project and it’s actually pretty similar to veggiesaurus’ idea. Here is how I am doing it:
I have a Spawner class that I built with a Sphere component (PickupCheck) and a Scene component (Spawn Point):
Then I hooked it up like so:
The “IsBatterySpawned” bool is default True. Essentially I am spawning in the pickup blueprint, then when the player overlaps the area it would will do a check to see if the pickup is no longer there (My pickups will not destroy if you have full ammo/battery, so players could come back later). After that, it just does a simple delay and respawn. Let me know if you have any questions.
Cheers,
I tried replicating this exactly how it is and it spawns initially, but never re-spawns again. Can anyone see what I am doing wrong here??
I forgot to set the collisions. Fixed. Thanks for looking!
Here is a BP I did with a random item variable and timer function so different items will appear at the specified time variable. Hope it’s Helpful!
][1]