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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

How to get Animation Blueprint refrence for casting

Hello, I have an animation blueprint attached to a SkeletalMeshActor, and I need to cast to it either from a component blueprint on the same object, or the level blueprint. I need to set a variable used in the animation from a separate component. I have not been able to get an object reference to cast to. If someone can help, I would really appreciate it. Thanks! PS: If anyone needs more info or some screenshots, I can add them.

Product Version: UE 4.22
Tags:
more ▼

asked Jun 11 '19 at 10:24 PM in Blueprint Scripting

avatar image

Scorpion_50
1 1

avatar image TorQueMoD 3 days ago

You don't need to cast to an animBP. What you want to do is create a variable for the animation inside the AnimBP and then call it from within your player character.

What exactly are you trying to do?

avatar image Scorpion_50 3 days ago

Thank you for the answer. Do you have any ideas of how to do this? Or a link to a documentation or something? What I am trying to do sounds very odd, but I have a live-updating rotator variable using logic that needs to be in a separate blueprint from the animation. I need that variable to be rotating a bone on my skeletal mesh.

avatar image TorQueMoD 3 days ago

Okay... can you give me more details on what it is you're planning to do? Like is this a weapon that spins in the character's hand or what? Because you might be going about it in the wrong way and telling me what you're hoping to do with more detail might allow me to make a better suggestion. Typically if you're storing a variable in the animBP and you want to set the value somewhere else, what you would do is create the variable inside your characterBP for example, and then inside the animBP you can get a reference to that character using GetPlayerCharacter, then cast it to your character specifically and then get the variable from there and set it in your AnimBP. Then any changes you make to the variable in your character will feed into the AnimBP. Here's a basic example: https://www.youtube.com/watch?v=Y6RxHCpCTDI

But like I said, if you can give me specifics on why you're trying to rotate a bone and under what circumstances, then maybe I can tell you a better way to do it.

avatar image Scorpion_50 3 days ago

I am trying to animate the finger of a hand, and I need the separate blueprint because the game needs to communicate with hardware over UE4Duino. My problem with using a character blueprint is that I have not been able to access it, presumably because the hand is a SkeletalMeshActor, that is why I have tried adding a blueprint component. My main problem has been with getting an object reference to cast to, but if there is a better way to do it, I am open to that. Thank you for the response!

avatar image TorQueMoD 3 days ago

Oh it's not for a game but a robot? That would make more sense because otherwise I was just going to say it's easier to simply create an animation to move the finger and trigger it :P Here's a quick video on how to do basically what you want. It's showing how to get the character's head to rotate in the same direction the camera is facing so you could easily adapt it to move your finger however you like using a similar concept: https://www.youtube.com/watch?v=gDpTInfUeKg

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

2 answers: sort voted first

get all actors of class or referencing in the Game Instance/Game Mode/Pawn , no?

more ▼

answered Jun 12 '19 at 12:04 PM

avatar image

6r0m
424 17 16 26

avatar image TorQueMoD 3 days ago

to get the aniBP you just get a reference to the character and then cast to your specific character. The AnimBP is part of the character so that's the easiest way.

avatar image 6r0m 3 days ago

indeed, get all actors of specific class or in the begin play of specific class set in global instance above and the casting to anim bp of this specific class.

avatar image Scorpion_50 3 days ago

Yes, but I have so far not been able to get a reference to the character using get all actors of class, because I was unable to select the class of my actor.

avatar image Scorpion_50 3 days ago

Thank you for the response, but I have tried using get all actors of class, and I am not able to select the class of my actor (not sure why) and my needs would not let me use game instances or game states.

avatar image 6r0m 3 days ago

what about in the begin play of your custom class - get game pawn (cast to him) and set variable of self directly to the pawn?

also you can add tag to your class and check this https://www.youtube.com/watch?v=PKBQyTtS62g

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

My apologies, I should have just given you an example without assuming your knowledge...

Here's how you reference your animBP from any blueprint, level, character or custom:

alt text

The way casting works is you've got a generic object, in this case, the Player Character node. Casting is a way of saying, check to see if this generic PlayerCharacter is actually My Specific Player Character. If it is, then you can access the specific variables you create inside your character. If it's not, then it will fail.

Then with your player character, there's ALWAYS a skeletal mesh. This is inherited from the base code. So you can always get the mesh from any character. Whether or not a mesh has been set is another thing entirely. Once you get the mesh, it usually comes with an associated AnimationBP (provided you're using it as a character mesh) so you need to grab a reference to the Generic animationBP which is done with the AnimInstance node and then you have to see if this generic animbp is actually using your Specific animBP. If it is, then you can access all of your custom variables from within the animBP.

You don't necessarily need to create a duplicate variable inside your character, you could skip that step and just go straight into setting the variable inside your animBP but it's easier to reference the character and simply adjust it's variable and have your animBP getting a reference to the var inside your character to drive its own values. To do that, inside your animBP's event graph you would get a reference to the PlayerCharacter again and then grab the variable inside it and use that to set the var inside the animBP like this:

alt text

Then from whatever BP you like, you can simplify the code by only getting a reference to your character and then setting its custom variable value and that will auto-populate to your animBP.

alt text

more ▼

answered Jun 12 '19 at 07:47 PM

avatar image

TorQueMoD
1.2k 82 112 144

avatar image Scorpion_50 2 days ago

When I tried adding a character blueprint to my Mesh, which turned it into an actor, it immediately had compiling errors without any code in it. The error was that it contained invalid data, and to check the MapCheck log for details. The MapCheck log had no errors or warnings. What can I do to solve this?

avatar image TorQueMoD 2 days ago

I think you need to view a tutorial on how to actually create a character blueprint: For the quick setup, this video is good. https://youtu.be/Qzd4oU0tkVA

For a detailed setup completely from scratch, this one is great too: https://www.youtube.com/watch?v=iSxNwvZDKag

avatar image Scorpion_50 yesterday

Thanks, I tried creating a new actor blueprint from scratch and adding the mesh manually, and that fixed it. I was then able to cast to the animation instance of the mesh. I was not able to use my own AnimBP, I had to modify the existing one (even though I changed the animationBP on the mesh)

(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