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"

Randomize animation play?

Hello!

alt text

So in this setup, I need to trigger an animation by a Key Event, that will play on a random character.

My BP is set up like this already: alt text

To clarify, the clones in the background are supposed to follow the main player's animations, and I want a way where they can start falling down at random.

Product Version: UE 4.19
Tags:
22.png (1.2 MB)
capture.png (161.0 kB)
more ▼

asked Apr 03 '18 at 12:05 PM in Blueprint Scripting

avatar image

mestrategos
5 1 4

avatar image EvilCleric Apr 03 '18 at 01:22 PM

Falling down to the ground or falling down to the infinite? With a new or the same animation?

avatar image mestrategos Apr 03 '18 at 05:22 PM

To the ground using a new animation.

(comments are locked)
10|2000 characters needed characters left

3 answers: sort voted first

Is the new animation a new state or a new Animation BP.

If it's a new animation BP then, in the player event graph:

alt text

Press R, and it will randomly select a character and set the new animation.

animation.png (104.5 kB)
more ▼

answered Apr 03 '18 at 06:44 PM

avatar image

EvilCleric
476 3 5 12

avatar image mestrategos Apr 04 '18 at 10:47 AM

Thank you! I'm only starting to learn BPs and can't seem to be able to find/add that "Target" socket?

alt text

3.png (55.1 kB)
avatar image EvilCleric Apr 04 '18 at 12:02 PM

Take a wire from the output of "GET" and select "Get Mesh":

alt text

getmesh.png (142.3 kB)
(comments are locked)
10|2000 characters needed characters left

So the Get Mesh node won't show up unless I uncheck Content Sensitive..alt text

And when I do, I get this node which only has one socket still

alt text

I know I'm probably doing something wrong, just can't figure out what..

Could it be that I got the wrong "Get" node? alt text

which-get.png (120.8 kB)
get1.png (100.2 kB)
get2.png (38.5 kB)
which-get.png (120.8 kB)
more ▼

answered Apr 04 '18 at 02:30 PM

avatar image

mestrategos
5 1 4

avatar image EvilCleric Apr 04 '18 at 03:12 PM

In "Get All Actors of Class" make sure to select the characters' class.

avatar image mestrategos Apr 04 '18 at 03:18 PM

That did it, thank you!

avatar image mestrategos Apr 13 '18 at 08:41 AM

Hello again :D. One last thing, and I'm sorry to be so greedy with your generosity; Would there be a way to make sure that once a character has played the death animation, it stays down and doesn't jump back up when I trigger any of the other animations? I explain it a little better here: https://answers.unrealengine.com/questions/776509/subtracting-clones-from-group-animations.html

avatar image EvilCleric Apr 13 '18 at 02:40 PM

There are several ways. Here is one:

If the number of characters is the same throughout the game and their number is fixed (not continuously spawned), then put all actors in an array.

Then every time you press "J" to randomly select a character, instead of using "Get All Actors", you will randomly select an actor directly from this array, play the death animation and then remove the character from the arraw, using the node "Remove".

(I can't show any BP, because I'm not at home.)

avatar image mestrategos Apr 13 '18 at 05:01 PM

Having trouble adding the characters to an array. It won't allow me selecting the character "homegirl" in the Array Elements field. Thinking I'm selecting the wrong variable type..

alt text

array.png (285.0 kB)
avatar image EvilCleric Apr 13 '18 at 05:58 PM

How are putting the characters in world? Are you creating them at run-time? Or are they already in the world before you start playing? If so, then:

alt text

And then:

alt text

new2.png (25.1 kB)
new.png (104.8 kB)
avatar image mestrategos Apr 13 '18 at 06:30 PM

Thank you for the reply! My issue is creating an array that carries the characters. The characters are already there before play, and whenever I try to add them to an Actor-tpe variable, it doesn't work. They simply won't get added to the Array Elements.

avatar image EvilCleric Apr 13 '18 at 06:36 PM

Since the characters are already in the world, just do it as in the first pic. As soon you start playing, the array will be automatically populated, so no need to set size or add them manually.

avatar image mestrategos Apr 13 '18 at 06:52 PM

alt text

Set it up like this, and it isn't working :/ There's a couple of Get and Remove nodes available, and this is the only configuration that is compatible. What am I doing wrong? :'(

Again, very very thankful for your patience!

image.png (343.7 kB)
avatar image EvilCleric Apr 13 '18 at 07:06 PM

1 - at the "Begin Play" event:

    • attach a "Get All Actors of class"

    • select the correct "Actor class"

    • drag a wire from "out Actors" and select "promote to variable"

    • rename the newly created array variable as "xxx" (whatever you want)

2 - at the "Z" key event:

    • remove the "Get All Actors of class"

    • from the list of variables, drag "xxx" and select "get"

    • connect that to all places places where the array is needed:

alt text

newnewnew.png (328.1 kB)
avatar image mestrategos Apr 13 '18 at 08:23 PM

alt text

alt text

Tried both ways (see screenshots) and it does seem to work, but not the way I want. Some characters do get removed, but some of those are the ones still standing (have not played the death animation, and thus unable to die). I just want the characters who have died to stay dead (lol) and to still be able to randomly kill off the remaining ones.

1.png (272.1 kB)
2.png (328.4 kB)
avatar image EvilCleric Apr 13 '18 at 08:55 PM

Sorry, my bad. There was a error from my part.

Your second pic is right, but requires a little correction. When "Remove Item" is called, it gets a new random number, and therefore it can select another character other than the one that died. So the solution is to save the random index in the first time in a variable and then use it for both the "Get" and the "Remove". Something like this:

alt text

Sorry for the design.

corrected.png (121.8 kB)
(comments are locked)
10|2000 characters needed characters left

Finally got it to work. No clue as to what the logic is, but it worked!

alt text

Thank you @EvilCleric. Wouldn't have even gotten close without your help/extreme patience :'D

solution.png (336.8 kB)
more ▼

answered Apr 13 '18 at 08:53 PM

avatar image

mestrategos
5 1 4

avatar image EvilCleric Apr 13 '18 at 09:09 PM

That shouldn't work.

That "Set" should be connected to the exit of "random integer" in order to save the generate random int, and the output of this "Set" connected to the "Get" and to the "Remove".

The way it's now, the "Set" is doing nothing.

avatar image EvilCleric Apr 13 '18 at 09:13 PM

Perhaps my pic was too messy. In my pic, when lines crosses have an arc, it means they are bridges (they are not connected). Only when they have a full red circle, it means they are connected.

(comments are locked)
10|2000 characters needed characters left
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