1
This commit is contained in:
32
Unity/Scripts/Entity/Components/Physics/EntityPhysics.cs
Normal file
32
Unity/Scripts/Entity/Components/Physics/EntityPhysics.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit.Entities
|
||||
{
|
||||
public class EntityPhysics : EntityComponent, IHealthCallback
|
||||
{
|
||||
public Animator animator;
|
||||
public Rigidbody[] rigidbodies;
|
||||
public Collider[] ragdollColliders;
|
||||
public override void OnStart()
|
||||
{
|
||||
entity.RegisterCallback<IHealthCallback>(this);
|
||||
}
|
||||
void IHealthCallback.OnSetAlive(bool alive)
|
||||
{
|
||||
if(animator)
|
||||
animator.enabled = alive;
|
||||
rigidbodies.ForEach(x =>
|
||||
{
|
||||
x.isKinematic = alive;
|
||||
});
|
||||
ragdollColliders.ForEach(x =>
|
||||
{
|
||||
x.enabled = !alive;
|
||||
});
|
||||
}
|
||||
public void OnSetHP(int hp)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user