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"

Setting up a Key Event

Hey, I'm trying to set an animation state variable in an anim BP so that a character switches animation based on my custom variables; I'm trying right now to bind the state switches to keys for testing purposes. What's the simplest method for achieving this? I currently have a 'Chase' State linked to a cone-of-sight calculation and it works, so all I need to do is bind these variables to keys. Thanks in advance!alt text

Product Version: UE 4.13
Tags:
key_event.png (215.3 kB)
more ▼

asked Nov 10 '16 at 11:53 AM in Blueprint Scripting

avatar image

ElizeSinka
13 4 8 11

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

1 answer: sort voted first

In your actor you'll have key events. Those events will set variables. Your actor will reference your animation blueprint. Your animation blueprint will obtain the actor by using "Get Owning Pawn" or "Get Owning Actor". You'll then cast that to your actor class that is setting the variables on input events. You can drag off from the result and get the variables you want then set your animation blueprints variables to the values you got from your actor.

Good luck!

more ▼

answered Nov 10 '16 at 01:24 PM

avatar image

Grant Margison
86 7 15 21

avatar image ElizeSinka Nov 10 '16 at 03:04 PM

This is what I have so far:![alt text][1] [1]: /storage/temp/114465-2.png

Currently this does not work (I am setting up the key events in my FirstPersonChar. and the AnimBP references an NPC who's animations I am controlling). If, in my FPC blueprint I do not include the Cast, the BP runs and the key press is recognised, though nothing changes in the NPC's animations.

1.png (258.0 kB)
2.png (104.1 kB)
avatar image Grant Margison Nov 10 '16 at 05:08 PM

I see. What you need to do, is reference the NPC in your character blueprint somehow, "Get All Actors Of Type" or a collision check. Once your FPC blueprint has the NPC reference available you'll cast that ref to your NPC class and set variables on the NPC from your input events on FPC.

Open up your NPC and select the skeletal mesh component, use the animation blueprint of your choice. Then inside the animBP your "Update Animation" event should be setting it's variables from the NPC values.

That should work.

avatar image ElizeSinka Nov 10 '16 at 05:15 PM

Okay I'll give this a go thanks :)

(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