I have a simple code that will be enabled when I kick, so I disable it right away but even though it is disabled, it works somehow. can it be because of his parent or something else I dont know of?
//this is the script Kick_Test, i dont reach it from anywhere else
private GameObject ball;
private Rigidbody2D rg2d;
public int power = 30;
void Start()
{
ball = GameObject.FindGameObjectWithTag("Ball");
rg2d = ball.GetComponent<Rigidbody2D>();
this.enabled = false;
}
private void OnTriggerEnter2D(Collider2D col)
{
if(col.tag == "Ball")
{
Debug.Log("KİCK");
Vector2 pos = (transform.position - col.gameObject.transform.position).normalized;
rg2d.AddForce(-pos * power, ForceMode2D.Impulse);
}
}
