33 lines
834 B
C#
33 lines
834 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using BITKit.FPS;
|
|
using UnityEngine;
|
|
|
|
namespace BITKit.Entities.Player.Feel
|
|
{
|
|
public sealed class PlayerHitMotion : EntityBehavior
|
|
{
|
|
[SerializeField] private Spring3 spring;
|
|
[SerializeField] private LocationAdditive locationAdditive;
|
|
[SerializeField] private AnimationCurve damageBasedMotion;
|
|
public override void OnStart()
|
|
{
|
|
UnityEntity.AddListener<DamageMessage>(OnDamaged);
|
|
}
|
|
|
|
private void OnDamaged(DamageMessage obj)
|
|
{
|
|
if (obj.Target != UnityEntity) return;
|
|
var damage = damageBasedMotion.Evaluate(obj.Damage);
|
|
spring.value = new Vector3(damage.Random(), damage.Random(), damage.Random());
|
|
}
|
|
|
|
public override void OnUpdate(float deltaTime)
|
|
{
|
|
spring.Update(deltaTime,default);
|
|
locationAdditive.AddEuler(spring.value);
|
|
}
|
|
}
|
|
|
|
}
|