Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class weaponScript : MonoBehaviour
- {
- public gameobject projectilePrefab;
- public bool launchable;
- private projectile projectileScript;
- void Update{
- if(launchable){
- GameObject projectileIntantiated = Instantiate(projectilePrefab, firePoint.transform.position, transform.rotation);
- projectileScript = projectileIntantiated.GetComponent<projectile>();
- projectileScript.parentWeapon = this.gameObject.GetComponent<weaponScript>();
- launchable = false;
- }
- }
- public class projectile : MonoBehaviour
- {
- public weaponScript parentWeapon;
- void OnCollisionEnter2D(Collision2D other){
- parentWeapon.launchable = true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment