public class enemy : MonoBehaviour {
public void DealDamage(float x) { health -= x; }
}
error
Assets/skrip/plyer/enemy1.cs(8,49): error CS0119: Expression denotes a type', where a variable’, value' or method group’ was expected
and here skrip for sword
using UnityEngine;
using System.Collections;
public class sword1 : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter(Collider other)
{
if(other.tag == “enemy”)
other.GetComponent().DealDamage(swordDamage);
}
}
what i get error from enemy script anda cannot solve this
Assets/skrip/plyer/enemy1.cs(8,49): error CS0119: Expression denotes a type', where a variable’, value' or method group’ was expected
i need to apply damage to enemy with make public void what its get error
using UnityEngine;
using System.Collections;
public class enemy : MonoBehaviour {
public void DealDamage(float x) { health -= x; }
}
and here skrip for sword
using UnityEngine;
using System.Collections;
public class sword1 : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter(Collider other)
{
if(other.tag == "enemy")
other.GetComponent<Enemy>().DealDamage(swordDamage);
}
}
Now remember classes are case sensitive so this will not work:
I would instead advise you to not change your getcomponent to a lowercase e, and instead always make sure your classes are pascal case (UpperCasedForEachWord) =)