using UnityEngine; public class CharacterController : MonoBehaviour { public Rigidbody characterRigidbody; public float swingForce = 10f; public float Health; public HingeJoint SpineHingeJoint; void Update() { // Control the character with horizontal input float input = Input.GetAxis("Horizontal"); characterRigidbody.AddForce(Vector2.right * input * swingForce); } private void OnCollisionEnter(Collision collision) { Debug.Log("Collided with: "+collision.gameObject.name); if(collision.gameObject.layer==LayerMask.NameToLayer("Obstacle")) { Health -= 0.5f; UIManager.instance.UpdateHealth(); } } }