0 votes
asked in AimIK by (200 points)
I use the aim IK 'axis' vector fields as an offset to get the correct positioning when pointing a weapon.  When I start the game these values recalculate or change to a different value.  How can i get a set axis to use as an offset that won't be changed?

1 Answer

+1 vote
answered by (2.4k points)
selected by
 
Best answer
Hey,

The axis vector is only normalized by AimIK (for performance reasons) when it initiates. It doesn't change the direction of the vector so it will not change the way AimIK behaves.
commented by (200 points)
Is there a better way to offset the position than axis vector? I use a different one for each weapon
commented by (2.4k points)

 If the problem is that your weapons have different axes pointing forward, then it would be better to use the hand bone as "Aim Transform" instead of the weapon.


Or you could apply offset like so:

public AimIK ik;
public Vector3 offset;
private Vector3 defaultAxis;

void Start() {
    defaultAxis = ik.solver.axis;
}

void LateUpdate() {
     ik.solver.axis = Quaternion.Euler(offset) * defaultAxis;
}

commented by (200 points)

ok ill try this.  thanks

commented by (200 points)
edited by
no matter what i set as the offset value, the axis stays the same.  

using:

aim.solver.axis = Quaternion.Euler(offset) * defaultAxis; in lateupdate and setting default in start.  

I can't seem to make it assign a value to the axis in the script.

---------------

edit:

i assigned the axis directly to the vector3 values and it works.  Thanks.

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.

...