How to Change (CENTER x ,y,z) of Capsule Collider Animation from Curve ? C#
Hi , I Changed Capsule Collider Height of an animations with curve & its fine , but my problem is how to change the position of that collider on (Center x,y,z)? Thank you !
GetComponent<CapsuleCollider>().height = myAnim.GetFloat("Ch"); //OK
GetComponent<CapsuleCollider>().center = myAnim.GetFloat("Ch1"); // Error
@Lockstep , @Nymisu, @crazyknight , @clunk47 , @urooba , @Menyus777 , @NoBrainer-David, @MaxGuernseyIII ,
Comment
Best Answer
Answer by Positive7 · Jun 01, 2018 at 02:01 AM
GetComponent().center is a Vector3. so something like
GetComponent<CapsuleCollider>().center = new Vector3(myAnim.GetFloat("Ch1"), myAnim.GetFloat("Ch1"), myAnim.GetFloat("Ch1"));
Side note: Don't use GetComponent in FixedUpdate()
thank you @Positive7 , but how can i do that on curve? thats mean i creat 3 curves for X , Y ,Z ? with the same name and same float name? thank you again!
You create 3 curve call it whatever you want but for simplicity lets say x,y,z Then the code should look like :
GetComponent<CapsuleCollider>().center = new Vector3(myAnim.GetFloat("x"), myAnim.GetFloat("y"), myAnim.GetFloat("z"));