using UnityEngine;
using System.Collections;
public class Damage : MonoBehaviour
{
public int damage = 10;
void OnCollisionEnter (Collision collision)
{
if(collision.gameObject.tag == "Enemy")
{
collision.gameObject.SendMessage("Take Damage", damage, SendMessageOptions.DontRequireReceiver)
}
}
}
error CS8025: Parsing error
and
error CS1525: Unexpected symbol `}’
i HAVE NO IDEA WHERE I AM GOING WRONG!
You need a semi colon after
collision.gameObject.SendMessage (“Take Damage”, damage, SendMessageOptions.DontRequireReceiver)
using UnityEngine;
using System.Collections;
public class Health : MonoBehaviour
{
public float hitPoints = 100f;
public float currentHitPoints;
public GameObject explosion;
void Start ()
{
currentHitPoints = hitPoints;
}
public void TakeDamage (float amt)
{
currentHitPoints -= amt;
if( currentHitPoints<= 0)
{
currentHitPoints = 0;
Die()
}
}
void Die()
{
Debug.Log ("Enemy Object Has Died");
}
}
Sorry about this but when i debugged it gave me a same error what now?
Die() needs a ; at the end.
If it gave you the same error, it usually means its the same error =) (it can mean many things, but can give you an idea of where to look)
I see thanks but i dont see it on my console does this mean something is wrong in the script
You dont see what? the debug.log in the die method? Are you calling the take damage script enough times to activate the die?
well within my health and dmage script its still not working… i recheck both sc cripts 10x or more but something isnt working its not taking damage so mabe there is a problem with the script or collider
Korno
August 16, 2015, 1:23pm
9
collision.gameObject.SendMessage("Take Damage", damage, SendMessageOptions.DontRequireReceiver)
Delete the space between Take Damage so it is TakeDamage.
Like this -
collision.gameObject.SendMessage("TakeDamage", damage, SendMessageOptions.DontRequireReceiver)