Hello everybody,
during this chapter I browsing a lot the Unity documentation and it leads me to write something like this :
if (hit.collider.TryGetComponent(out CombatTarget target)) {
if (Input.GetMouseButtonDown(0)) {
GetComponent<Fighter>().Attack(target);
}
}
What do you think about that ?
It’s seems to be more or less the same thing that the transform.GetComponent do and I used to use the transform.GetComponent way but I found this solution “cute” and clean.
Let me know
Regards !