+1 vote
asked in AimIK by

I have an empty object that determines where to fire the effects for my gun, at the tip of the gun.  I am also using the script you have in your forum SecondHandOnGun, although it still occurs with just using aimIK + fbbik

When using this, the position that the bullet fires is different than the location that is used to mark the end of the gun.  You can see in the pic below that the red line is the debug ray i am drawing from the end of gun object, and the object is selected in the scene so you can see the position of the actual object is end of the gun and it doesn't align with the red debug ray starting point.

Any idea what is going on? its throwing a bunch of my objects that are placed on the character model into wack because the position is off.

1 Answer

+1 vote
answered by (2.4k points)


It is a problem with the update order of things. If the problem is about particle FX, then the problem is that Unity particles are updated after internal animation update, but before LateUpdate, which is where Final IK components normally update their solvers (have to because they can't update in Update before the animation). So the particles get spawned from the animated position of the gun muzzle, ignoring the IK.

Because we can't change the order when the particles are updated, these are the possible solutions:

1. Do not parent the particle systems to the gun, make a script that set's their position to the muzzle in Update(). The particle FX will lag a frame behind, but that will not normally be noticable.

2. Disable the IK components and the Animator, call animator.Update(Time.deltaTime) and then ik.solver.Update() on each IK component in Update(). Not recommended as having the Animator disabled disables the Mecanim Live Link option.

If the problem is about spawning bullets or other custom scripting that requires reading the IK-d position of the gun, you'll have these options:

1. Use LateUpdate() to spawn the bullets and add the script that does so to a higher value in the Script Execution Order than Final IK components have.

2. Disable the IK components and update their solvers by calling ik.solver.Update any time before you spawn the bullets, but not before the internal animation update.

3. Use the ik.solver.OnPostUpdate() delegate to spawn the bullets, like so:

           void Start() {

                ik.solver.OnPostUpdate += AfterIK;


            void AfterIK() {

                // Spawn bullets here


Welcome to RootMotion Q&A, where you can ask questions and receive answers from the developer of Final IK and PuppetMaster and other members of the community.

Post as a guest, create an account or login via Facebook.

Please use the correct category when you post your questions.