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"

How to play animation when player clicks an actor?

I already have the animation ready, i just don't know how to play it when player clicks a cube.

Product Version: UE 4.19
Tags:
more ▼

asked Jul 01 '18 at 06:55 PM in Blueprint Scripting

avatar image

kubawww1
5 1 4

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

2 answers: sort voted first

Have you tried using an "on clicked" event? You can create one of these by selecting your Cube mesh component in the BP and at the bottom of the right hand details panel there are a bunch of green "+" signs one of them is for an "on clicked" event.

more ▼

answered Jul 01 '18 at 08:05 PM

avatar image

Nebula Games Inc
5.4k 28 9 15

avatar image kubawww1 Jul 01 '18 at 08:20 PM

but i can't access the animation, i can access it only in level blueprint

avatar image Nebula Games Inc Jul 01 '18 at 08:22 PM

What do you mean you can't access the animation? Doesn't your cube BP have the animation as part of its BP? Or do you mean you used something like sequencer or matinee and created an animation for the cube in your level? Also, just so I am clear...this cube...is it a BP or just a static mesh actor?

avatar image kubawww1 Jul 01 '18 at 08:26 PM

The cube is a BP actor and i created a matinee animation

avatar image Nebula Games Inc Jul 01 '18 at 08:46 PM

You would have to do something like this then.

alt text

matinee.jpg (82.0 kB)
avatar image kubawww1 Jul 01 '18 at 08:51 PM

Oh wow, i will try that tomorrow, i will inform if it worked because I'm going to sleep now.

avatar image ThompsonN13 Jul 01 '18 at 09:02 PM

you can also get the on click event for your cube in the level bp. you just need to select the cube in the level then in the level bp right click the graph then select "add event for" -> input->mouse input-> add on clicked.

alt text

capture.png (53.9 kB)
avatar image kubawww1 Jul 02 '18 at 07:13 AM

Thanks, it worked! Now, is it possible to play the animation when player points on the cube and clicks E?

avatar image kubawww1 Jul 02 '18 at 07:13 AM

Thanks, it worked but i prefer Thompson's method.

avatar image Nebula Games Inc Jul 02 '18 at 10:21 AM

That's fine we are basically saying the same thing haha As for your other question, yes you can. You need to have a line trace running, break the hit result, check if the hit actor is the cube and if yes allow E keyboard event to play the animation. So E would have to be hooked up to a branch node that checks if the out hit actor is the cube if true play animation otherwise do nothing.

avatar image kubawww1 Jul 02 '18 at 06:12 PM

I did another thing - created a boolean named "IsPointingButton", created an event for the cube "OnCursorBeginOver set boolean to yes" and "OnCursorEndOver set boolean to no" and now if player clicks E and if boolean is YES, open the door

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

You should do this in 2 steps. Firstly, create an intractable area into your cube BP Like a sphere, in which your character will be able to interact with the cube. Then just share a variable between your cube BP and your character one, thanks to the "get play controller" and "cast to third person ch" nodes. Then if your character is in the collision box/sphere, you should use an input event. On press, just check if your character is in the collision box, if true, set another variable to true like "play animation", and then you can cast it from your anim BP. You'll just have to get it in there and to use it as a transition to a new state, which will play your interaction animation. Let me know if it helps :p

more ▼

answered Jul 01 '18 at 09:35 PM

avatar image

Soockona
46 1 3

(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