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 ,

alt text
alt text

Yes that actually solved it! Now it works, the only flaw is that when it repeats the dialog, it skips the first line, meaning when it starts its blank where the first line should be, but the rest works!

2 Answers

2

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!

@Positive7 if u have other method for change animation collider height and position please tell me

@jackmw94 I want the explosions to be different type of attack that l want to launch rigid bodies and kill enemies. I just don't know where to start. My explosion is an object particle child of my projectile.