x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Spawning Items

So I created a system that spawns a coin when I kill an enemy. I have 2 problems I can't seem to overcome and I think I am overthinking it at this point.

1) If i spawn multiple enemies only the first one will drop the coin.

2) Is it possible to draw a random number (This part I know how to do) and use that number to generate how many coins are spawned.

Product Version: UE 4.9
Tags:
more ▼

asked Oct 27 '15 at 03:09 AM in Blueprint Scripting

avatar image

mikezteh69
37 8 12 16

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

1, seems weird, wouldnt you just spawn the coins on death? if so, then the number of enemies spawned shouldnt matter.

UNLESS, you are "spawning" them by placing them in the world, and using an exposed variable to set a value for the number of coins dropped.

2, Yes, there are random number nodes, clamp it to a certain range, feed it into a for loop, the for loop has a max loop count of (random number) each time the loop passes, it spawns another coin, until it hits the loop count.

more ▼

answered Oct 27 '15 at 04:31 AM

avatar image

MrGrr
986 34 3 41

avatar image mikezteh69 Oct 27 '15 at 04:11 PM

For debug I am spawning them by clicking in the world. I will use traditional pawn spawning and see if that helps. That is an interesting idea, I didn't think of.

As far as the loop for the coins, I will try and recreate what I did that didn't work because it was the same idea. When I do that i will post an image of the BP structure. Usually when I run into these issues it is very simple mistakes that cause me big problems.

avatar image mikezteh69 Oct 28 '15 at 12:52 PM

So I was spawning the enemies just by hitting space-bar originally...turns out that they would spawn a coin on death. The first coin would spawn at the site of the death. The subsequent coins spawn half way across the map...so I need to figure that out now..

avatar image MrGrr Oct 28 '15 at 09:49 PM

Potentially you are spawning them after destroying the actor, in which case the coins would spawn at world origin.

or you store a variable for the location, and spawn using that position....

or you destroy the actor after the coins have all spawned, using the completed node on the for loop.

avatar image mikezteh69 Oct 29 '15 at 03:05 PM

Have a look at the screen shots. I am spawning the coin(treasure) after death but I am using the location of the death.

The strange part is that the first enemy I spawn and kill it will work as intended, all additional spawns is what breaks it.

1.jpg (104.5 kB)
2.jpg (93.3 kB)
3.jpg (65.5 kB)
avatar image MrGrr Oct 29 '15 at 08:46 PM

What i see is, you destroy the actor, and then spawn the coin.

The node you have pulled off for the transform is lost the moment you destroy the actor.

You could drag off the pin and "Promote to variable", and then set the variable with the current location, in which case it would persist after "death" of the actor

Or even easier.... put the destroy actor node last.

Also, in the screenshots, you only spawn one coin? (or does your other blueprint spawn multiple?)

avatar image mikezteh69 Oct 30 '15 at 08:48 PM

YES this solves it. It was so simple but I get so wrapped up I miss these things..

Yes in the version I posted I am only spawning one coin. I didn't want to create a dev glad for UI testing so I am using the BP that does not have the random value spawner.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question