# passing a variable to animation blueprint to control ik

**URL:** <https://forums.unrealengine.com/t/passing-a-variable-to-animation-blueprint-to-control-ik/3634>\
**Category:** Blueprint\
**Tags:** unreal-engine\
**Created:** [May 1, 2014, 9:52pm UTC](https://forums.unrealengine.com/t/passing-a-variable-to-animation-blueprint-to-control-ik/3634 "2014-05-01T21:52:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bazmod](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@bazmod](https://forums.unrealengine.com/u/bazmod)\
**Post date:** [May 1, 2014, 9:52pm UTC](https://forums.unrealengine.com/t/passing-a-variable-to-animation-blueprint-to-control-ik/3634/1 "2014-05-01T21:52:23Z")

</div>

Hi, I’m trying to do something that I feel should be very simple but just cannot get it to work…

What I want to do is have an object in my level that can potentially move around, and then get a character to reach out towards the object or grab it using IK

The problem that I’m having is that I just cannot seem to pass a variable with the location of the object onto my animation blueprint. I’ve tried all sorts of methods such as blueprint interfaces, searching an array of the object types etc…

I can access the location easily enough in every blueprint other than the animation blueprint and I can move the IK to a location I specify in the animation blueprint. I just can’t work out how to put the two together.

I feel as though I must be missing something… any advice on the best way to set this up?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_3c2f6088](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_3c2f6088](https://forums.unrealengine.com/u/anonymous_user_3c2f6088)\
**Post date:** [May 1, 2014, 11:01pm UTC](https://forums.unrealengine.com/t/passing-a-variable-to-animation-blueprint-to-control-ik/3634/2 "2014-05-01T23:01:39Z")

</div>

Not sure if this is what you need, but try something like:

 ![Screenshot 2014-05-01 15.57.40.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/3/0/0303ccd5b6472eab87c8772b321ae257abc52c14.png)

---

<div class="post-metadata">

**Author:** ![bazmod](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@bazmod](https://forums.unrealengine.com/u/bazmod)\
**Post date:** [May 2, 2014, 9:47am UTC](https://forums.unrealengine.com/t/passing-a-variable-to-animation-blueprint-to-control-ik/3634/3 "2014-05-02T09:47:21Z")

</div>

thanks for the reply but I’m not sure I’m totally following what this does or where that blueprint should be located?

Basically all I need to do is to pass a variable into the anim BP but I just constantly get ‘variable is not in scope’. I have no idea what this means…? Here is a simple version of my BP to show what I’m trying to do:

This is in my character blueprint. The ‘Target Actor’ variable is set to editable so I can pick the target from the scene. This part is all working fine

 ![characterBP.PNG](https://d3kjluh73b9h9o.cloudfront.net/original/3X/6/1/61457cef73fc5d0c56066340f6c71a046bb3084e.png)

next in my animation BP I’m passing this value in and assigning it to a variable. This is where I’m having an issue as the variable is not being passed (I get ‘variable is not in scope’ when running the game:

 ![animEventGraph.PNG](https://d3kjluh73b9h9o.cloudfront.net/original/3X/3/f/3f59774566e4d82d16f8261a32a9a96e523d1e9e.png)

finally I use this set variable to move the IK (this bits working fine provided I could set that variable):

 ![animAnimgraph.PNG](https://d3kjluh73b9h9o.cloudfront.net/original/3X/c/d/cda286437c1867be7f81d860c8e275312782715a.png)

Again thanks for any help or to anyone that can shed some light on this 🙂 Seems like it should be such a simple thing to do!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_3c2f6088](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_3c2f6088](https://forums.unrealengine.com/u/anonymous_user_3c2f6088)\
**Post date:** [May 2, 2014, 9:59am UTC](https://forums.unrealengine.com/t/passing-a-variable-to-animation-blueprint-to-control-ik/3634/4 "2014-05-02T09:59:26Z")

</div>

I’m still learning this stuff myself, but I would try to use the mesh component in your character blueprint to get it’s amin instance, cast it, then use the cast to set the animation variable. Good luck 🙂

---

<div class="post-metadata">

**Author:** ![bazmod](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@bazmod](https://forums.unrealengine.com/u/bazmod)\
**Post date:** [May 2, 2014, 10:45am UTC](https://forums.unrealengine.com/t/passing-a-variable-to-animation-blueprint-to-control-ik/3634/5 "2014-05-02T10:45:54Z")

</div>

Fixed it! 🙂 It turns out that it was working all along… but for future reference or anyone having similar issues here’s what was causing me grief.

Having a look at the contents example file they also have the ‘variable out of scope’ once its been cast, so just ignore this. I’m not sure what that means so I don’t know if its intended or a bug or just a lack of functionality (it certainly makes things harder to bug fix though when you can’t trace your variable being passed around).

The problem that I had is that I simply needed to change the end effector in the ‘2 bone IK’ node to be in world space rather than component space. Makes complete sense really as I am passing in the location of an object in the world! Anyway that took me a whole day to work out haha :rolleyes:
