Hi, I used this script on player character
void OnControllerColliderHit(ControllerColliderHit hit)
{
if(hit.collider.tag=="sword_enemy")
{
col="hit";
live--;
}
}
but after collide , live shows -189 or more, this result is for one collide not more, how can i fixed it? one collide and one live--
i tried by OnTriggerEnter,too and that result was wrong
this is my complete code
using UnityEngine;
using System.Collections;
public class playerCollid : MonoBehaviour {
public string col="";
public int live=5;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnControllerColliderHit(ControllerColliderHit hit)
{
if(hit.collider.tag=="sword_enemy")
{
col="hit";
live--;
}
}
void OnGUI()
{
GUI.Label(new Rect(2,2,100,100),live.ToString());
}
/*
void OnTriggerEnter(Collider other)
{
if(other.tag=="sword_enemy")
{
print("trigger");
}
}
*/
}