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.
25 lines
685 B
C#
25 lines
685 B
C#
2 months ago
|
using CnControls;
|
||
2 months ago
|
using UnityEngine;
|
||
|
|
||
|
public class CharacterController : MonoBehaviour
|
||
|
{
|
||
2 months ago
|
public Rigidbody characterRigidbody;
|
||
2 months ago
|
public float swingForce = 10f;
|
||
2 months ago
|
public float Health;
|
||
|
public HingeJoint SpineHingeJoint;
|
||
2 months ago
|
|
||
|
void Update()
|
||
|
{
|
||
|
// Control the character with horizontal input
|
||
2 months ago
|
float input = CnInputManager.GetAxis("Horizontal");
|
||
2 months ago
|
characterRigidbody.AddForce(Vector2.right * input * swingForce);
|
||
|
}
|
||
2 months ago
|
private void OnCollisionEnter(Collision collision)
|
||
|
{
|
||
|
if(collision.gameObject.layer==LayerMask.NameToLayer("Obstacle"))
|
||
|
{
|
||
|
Health -= 0.5f;
|
||
|
UIManager.instance.UpdateHealth();
|
||
|
}
|
||
|
}
|
||
2 months ago
|
}
|