How can I get the mesh my anim blueprint is attached to?

I’ve got an anim blueprint that’s on the mesh of an enemy character. I’m trying to spawn a projectile off the socket of this character, but I don’t know how to get a reference to the mesh from within the anim blueprint. How do I do that?

I assume you can use “Get owning actor” and from there on you can cast to the appropriate blueprint class. Is that gonna work?

I figured it out. It turns out that the owner is the actor that owns it and you have to use “Get Component By Class” and choose “Mesh.” In my case, there’s only one mesh, so that makes things easy. Otherwise, you’d have to go through the array and identify which mesh you want.

I’m surprised that there isn’t an equivalent to “get owner” that gets the mesh the anim blueprint is attached to. If there is, please let me know.

Owning actor doesn’t refer to the Mesh that the blueprint is attached to (which is surprising). See my answer for the way to get the Mesh.

I may misunderstand something, but you try to get the mesh of your pawn right? In that case, make sure to cast your “Owning actor” to your appropriate class, that cast node will get you the specific type, which if you drag out from that, will get you a reference to “Mesh”. I’ve attached a screendump. So correct me if im wrong, and that’s not what you wish to achive.

Few notes about this approach:

  1. it is better ran on initialization only, and get set to a variable that will later used, rather than using it every tick (for performance sake)

  2. it will not work if the mesh has no actor, so be cautious.

Old thread, but it popped up first for me when searching “get mesh from animation blueprint”.

It seems now this can be done with the “Get Owning Component” node:
image

6 Likes

This post is mostly for anyone who still runs into this common problem and the above points don’t work out.

A reason that finding the pawn can fail is when there’s a different skeleton for the Mesh (on the character) compared with the AnimBP skeleton. Even if the AnimBP can be assigned to the Mesh component in your Character BP, they may not actually match skeletons.

You can check by using RMB > Find Skeleton and Replace Skeleton etc.
Just be sure to save a copy of things first, because re-assigning a skeleton for all the animations and blendspaces and such can be time-consuming.

image

Note that I set the Char variable on the AnimSet from the character. Instead of the ‘get pawn owner’ way of looking up the character from the animset.