Cast to not working in Animation Blueprint for Bools
So in the character blueprint I have a variable "is crouching" and I cast to myCharacter to get this variable in the Animation Blueprint and it's not working in game. After some debug testing it seems as though the blueprint is appropriately taking in the input to make the character crouch and the animation plays correctly when I edit the values in the animation preview. (the event is labelled as "Dodge" but is meant to be used for crouching)
asked Mar 08 '15 at 02:27 AM in Blueprint Scripting
Here's how you cast to an animBP from a different BP. If you are casting to it from the player BP itself, you can just start with the Get Anim Instance node with the skeletal mesh component plugged into it.
Basically, the game needs to know which instance of the animBP to look at, and you need to supply the skeletal mesh in question. For what I used, the skeleton is called "betaguy." As long as you are pulling the player instance out of a casting, it will automatically use the skeletal mesh when you search for Get Anim Instance. Otherwise, you must manually supply its skeletal mesh.
The logic goes like this: Get Player Pawn > Cast to instance of player > Return player instance to get skeletal mesh > Get anim instance from that skeletal mesh > Cast to anim bp instance
Keep in mind that you can do all your casting on Begin Play or some other event, and store them as object variables. You drag the output object pin from a Cast node and select Promote to Variable at the top of the context window. That will save the actual instance of whatever BP you need to talk to, allowing you to grab events and functions and send data by simply dragging the output from a Get object variable node. It's essential for any complex and repeated communication between BPs. You should never cast between BPs more than once.
Let me know if you need more info! :)
In addition to the excellent answer provided by DG Gage, I think I see the issue in your current setup. If you take a look at your debugscreenshotone.png, you'll notice that the Object input on your Cast To MyCharacter node has been left unhooked. With this unhooked, the blueprint simply doesn't know what you'd like to perform the cast on. To fix this, drag off of a Get Pawn Owner node and connect it to the Object input of your Cast node. This will basically say, "get whatever pawn owns this anim blueprint and cast it to MyCharacter." I believe that should get you crouching ASAP.
answered Mar 08 '15 at 11:15 PM
Ray Arnett STAFF
Follow this question
Once you sign in you will be able to subscribe for any updates here