mirror of
https://github.com/frizbee19/FebGameJam.git
synced 2026-09-11 08:17:01 +00:00
AnimationControllerTester can set a specific animation (instead of cycling)
This commit is contained in:
3 files changed
+3210
-145
No files matched your search
@@ -2,16 +2,33 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public enum TestingBehavior {
|
||||
Cycle,
|
||||
Set
|
||||
};
|
||||
|
||||
public class AnimationControllerTester : MonoBehaviour {
|
||||
public Animator animator;
|
||||
public int numberOfAnimations = 1;
|
||||
public string animationPropertyName = "Animation";
|
||||
public TestingBehavior behavior = TestingBehavior.Cycle;
|
||||
public int setAnimationIndex = 0;
|
||||
|
||||
void Start() {
|
||||
if (animator == null) {
|
||||
animator = GetComponent<Animator>();
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update() {
|
||||
// Get current time
|
||||
int second = (int) (Time.time / 1.5f);
|
||||
int animationIndex = second % numberOfAnimations;
|
||||
animator.SetInteger(animationPropertyName, animationIndex);
|
||||
if (behavior == TestingBehavior.Cycle) {
|
||||
// Get current time
|
||||
int second = (int) (Time.time / 1.5f);
|
||||
int animationIndex = second % numberOfAnimations;
|
||||
animator.SetInteger(animationPropertyName, animationIndex);
|
||||
} else {
|
||||
animator.SetInteger(animationPropertyName, setAnimationIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user