Currently trying to use Ani.Mate to perform a translation and rotation at the same time but I’m getting the error: “InvalidCastException: cannot cast from source type to destination type”
Can anyone shed any further light on this, as I’m really not sure whats wrong with my code as it’s pretty much copy pasted from the AniMate wiki page!
My code (javascript):
yield Ani.Mate.To(this.transform, 0.5, {“position”: new Vector3(sledX,2.5,sledZ), “rotation”: Quaternion.Euler(0,sledRot,0), “drive”: SlerpDrive});
Note the sledX, Z Rot variables are all floats, could this be the problem?
Did a bit more experimentation with it, if I do each command separately (e.g. move then rotate) using Ani.Mate.To(… ) it works fine, but obviously looks wrong!
Anyone know what the problem is? I’ve not had much experience with Unity so any help is always appreciated
The drive you set applies to all properties you try to animate in the call. That means you can only mix animations that use the same drive.
The SlerpDrive (S stands for spherical) is only available to Quaternions. It then tries to cast anything you pass to a Quaternion, which fails for Vector3 in this case.
You’ll have to use two separate calls in this case.
(Incidentally the reason it looked awful was that it was supposed to be rotating smoothly round a corner, instead it moved in a straight line then rotated lol)