1
This commit is contained in:
31
Assets/Artists/Scripts/Feel/PlayerHitMotion.cs
Normal file
31
Assets/Artists/Scripts/Feel/PlayerHitMotion.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BITKit.FPS;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit.Entities.Player.Feel
|
||||
{
|
||||
public sealed class PlayerHitMotion : EntityComponent
|
||||
{
|
||||
[SerializeField] private Spring3 spring;
|
||||
[SerializeField] private LocationAdditive locationAdditive;
|
||||
[SerializeField] private AnimationCurve damageBasedMotion;
|
||||
public override void OnStart()
|
||||
{
|
||||
entity.AddListener<DamageMessage>(OnDamaged);
|
||||
}
|
||||
|
||||
private void OnDamaged(DamageMessage obj)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user