You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
FlyingFred/Assets/CharacterController.cs

25 lines
722 B
C#

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