- Home /
Legacy Animation Advice
I've been using the legacy animator to create the most basic looping translation animations for cube primitives, for use in a simple platformer game for example.
Now with mechanim out I'm very reluctant to continue using the legacy system, but mechanim doesn't provide the ability to create super simple animations like what I mentioned within unity.
Plus now that i think about it, scripting transform translations would probably work better because i could make a generic script with public vars for transform start and end locations and i can just attach it to any object i want to quickly animate, instead of having to create a new .anim for that object.
But i have a few questions:
The animation component has a checkbox "Animate Physics". If i for example script a stretched cube platform to translate back and forth between 2 points and i give it a kinematic rigidbody, would there still be proper physics interaction?
Also, in the legacy animation window, the animation curve keyframes really came in handy because i could make them "flat" in order to create a smooth animation that would prevent a transform from snapping back once it reaches an end point if you know what I'm saying. How could i script it like that?
Is there a generic script available that i can use for these simple animations?
Ok I made this code:
#pragma strict
var movePosition : Vector3[];
var speed : int;
private var positionIndex : int = 0;
function Update () {
if(transform.position == movePosition[positionIndex]){
if(movePosition.Length == positionIndex + 1)
positionIndex = 0;
else positionIndex++;
}
// Debug.Log(positionIndex);
transform.position = Vector3.$$anonymous$$oveTowards(transform.position, movePosition[positionIndex], speed * Time.deltaTime);
}
$$anonymous$$oveTowards isn't producing a nice smooth motion when compared to using the legacy animation system and flattening out peaks.
Also, I'm getting very slippery motion on the platform(im using a moving sphere) when compared to a platform using the legacy system. On the legacy system platform i checked "animate physics" and i attached a kinematic rigidbody.
On the scripted platform, i get slippery motion with or without the kinematic rigidbody. What can I do? If i can't fix this then I'm forced to use the animation system which would get really cumbersome with many animations.
I dont understand how animating a cube platform using the animation system gives proper physics interaction, but just translating the platform through scripting does not...
For both methods i have a kinematic rigidbody and a box collider. Somehow checking "animate physics" makes it all work properly. The sphere will actually roll on the platform ins$$anonymous$$d of sliding.
I guess i need help with two problems. One is with making the physics interaction between the sphere and platform work properly like i mentioned above, and second is to script the translation so that i looks like it was made in the animation window with flat peaks in the position curves.
I guess the second problem can possibly be solved with some interpolation tweaks but i really dont know about the first problem... any help is very appreciated.
actually now that i think about it, perhaps i might as well just stick with the legacy system and just use the empty game object moving trick to lessen the number of clips i have to make... $$anonymous$$ecanim is pretty new anyways and will probably have simple animation features added in the future anyways...
Plus i really dont see afix for the physics interaction thing anyways...
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
How do you set up a trigger animation without going through the collider? 0 Answers
Problem with new version (Unity > Animation) 0 Answers
Is it possible to manipulate Mecanim state machine / blend trees from scripting? 0 Answers