This commit is contained in:
CortexCore
2023-10-20 19:31:12 +08:00
parent 5cd094ed9a
commit a160813262
1878 changed files with 630581 additions and 4485 deletions

View 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);
}
}
}