I do some simple animations on rocks just to give them a bit of movement in my game. Is it possible to simulate the animations without being in play mode? (not with Mecanim)
Here’s what I got but it doesn’t simulate in the scene view
[ExecuteInEditMode]
public class AnimationHelp : MonoBehaviour
{
public float Delay = 0f;
private float DelayTimer;
public float AnimScale;
public float Speed = 1f;
[Range(0,1)] public float PrewarmPercent = 0f;
private Animation Animation;
void Start ()
{
Animation = GetComponent<Animation>();
DelayTimer = Delay;
Animation.playAutomatically = false;
transform.localPosition = Vector3.zero;
transform.localEulerAngles = Vector3.zero;
transform.localScale = Vector3.one;
}
void Update ()
{
Debug.Log("DelayTimer: " + DelayTimer);
if (Animation.isPlaying) return;
DelayTimer -= Time.deltaTime;
if (DelayTimer < 0)
{
var animState = Animation.CrossFadeQueued(Animation.clip.name);
animState.normalizedSpeed = Speed;
animState.normalizedTime = PrewarmPercent;
}
}
}