private void OnTriggerEnter2D(Collider2D col) { if (GetComponent <Transform>().parent.tag != "ThrowableHolder") //Not a prefab { if (exploded) { if (col.gameObject.GetComponent <Rigidbody2D>() != null) { Vector2 target = col.gameObject.transform.position; Vector2 bomb = gameObject.transform.position; Vector2 direction = power * (target - bomb); if (dampen) { float dampeningRatio = 1 - current_radius / explosion_max_size; direction *= dampeningRatio; } col.gameObject.GetComponent <Rigidbody2D>().AddForce(direction); } FirstCollision first = col.gameObject.GetComponent <FirstCollision> (); if (first != null) { first.collidedAfterLaunch = true; } } } }
private void atApexLogic() { if (catapultArmLogic.isAtMax) { power = minPower; if (loadedThrowable != null) { GetComponent <LaunchSim> ().endSim(); FirstCollision temp = loadedThrowable.GetComponent <FirstCollision> (); if (temp != null) { temp.startLaunchedTimer(); } } } }