Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Hybrid ecs
- public class AnimationControlComponent : MonoBehaviour
- {
- public bool disable_movement = false;
- public bool disable_rotation = false;
- public Animator assignedAnimator;
- }
- [UpdateAfter(typeof(PlayerInputSystem))]
- public class AnimationControlSystem : ComponentSystem
- {
- public struct State
- {
- public AnimationControlComponent animationControl;
- public CritterMovementComponent critterMovement;
- }
- protected override void OnUpdate()
- {
- var entities = GetEntities<State>();
- foreach (var entity in entities)
- {
- var xzImpulse = entity.critterMovement.directionToGo;
- xzImpulse.y = 0;
- entity.animationControl.assignedAnimator.SetFloat("movementSpeed", Vector3.Magnitude(xzImpulse));
- entity.animationControl.disable_movement = entity.animationControl.assignedAnimator.GetBool("disable_movement");
- entity.animationControl.disable_rotation = entity.animationControl.assignedAnimator.GetBool("disable_rotation");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement