MyScreensShot :
![](https://static.wixstatic.com/media/747d52_1e9e23d983b94525a2a8c2271ecbb6d8~mv2.png/v1/fill/w_980,h_485,al_c,q_90,usm_0.66_1.00_0.01,enc_avif,quality_auto/747d52_1e9e23d983b94525a2a8c2271ecbb6d8~mv2.png)
- Use Interface for Call Function invoke with Collision enter public interface IExplode
{
void Explode();
} Missile.cs
PredictMovement(leadTimePercentage); // คำนวนหาทิศทางเป้าหมาย
AddDeviation(leadTimePercentage); //ค่าเบี่ยงเบนของเป้าหมาย
RotationRocket(); // หมุน Missile
if(collision.transform.TryGetComponent<IExplode>(out var ex)) ex.Explode(); // Call Interface Function
Target.cs public class Target : MonoBehaviour,IExplode
Var Dir = Vector3(Cos(T*S),Sin(T*S));
public void Explode() => Destroy(gameObject); // เชื่อมต่อกันผ่าน Interface
--------------------------------------------------------------------------------------------------------
UNITY Auto SAVE
--------------------------------------------------------------------------------------------------------
Local Function Local Functions in C# - Stay Inside Me - YouTube
Comments