Question by
ogamelol134 · May 05, 2021 at 08:53 AM ·
errorobjectenemy
How do I get the name of the object I am attacking and how can I use it to select the game object name?
public void attackdamage()
{
snpc.GetComponent<Dusman>().ehealth -= 20;
}
private void OnTriggerEnter(Collider other)
{
pplayer = other.gameObject.name;
}
private void Start()
{
sns = GetComponent<Silah>().pplayer;
snpc = GameObject.Find(sns);
}
I take this error
bu-hata.jpg
(14.1 kB)
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613033308im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
*Solved* Loop instantiating objects causes my Unity Editor to crash 1 Answer
Cannot convert 'object' expression to 'float' 1 Answer
ERROR CS0029: Cannot implicitly convert type `UnityEngine.GameObject' to `TriggerSphere' 1 Answer
NullReferenceException: Object reference not set to an instance of an object 3 Answers