Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Change constrained axes at runtime on multi aim constraint?

Discussion in 'Animation' started by Kyle45, Dec 11, 2022.

  1. Kyle45

    Kyle45

    Joined:
    Apr 18, 2015
    Posts:
    10
    Hi, I am trying to turn off the x and z axes on a multi aim constraint when the player gets within 3 units of it. My code changes the bools in the inspector, but the constraint is still being applied to all three axes. Do I need to tell the job that I changed these values or something? Thanks.

    Code (CSharp):
    1.         bool val = Vector3.Distance(playerPos, transform.position) > 3f;
    2.         mainAimConst.data.constrainedXAxis = val;
    3.         mainAimConst.data.constrainedZAxis = val;