Kick start Unity

Tank settings
Bullets settings
Bird settings
using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.UI;public class movement : MonoBehaviour{public GameObject bulletprefab;public Transform firePoint;public float speed=3f;// Start is called before the first frame updatevoid Start(){}// Update is called once per framevoid Update(){float horizontal = Input.GetAxisRaw("Horizontal");transform.position+=new Vector3(horizontal*speed*Time.deltaTime,0f,0f);if(Input.GetMouseButtonDown(0)){fire();}}void fire(){Instantiate(bulletprefab,firePoint.position,Quaternion.identity);}}
using System.Collections;using System.Collections.Generic;using UnityEngine;public class destroy : MonoBehaviour{// Start is called before the first frame updatevoid Start(){}// Update is called once per framevoid Update(){}private void OnTriggerEnter2D(Collider2D other) {if(other.tag=="Bird"){Debug.Log("Bird");other.gameObject.SetActive(false);}}}
using System.Collections;using System.Collections.Generic;using UnityEngine;public class spawn : MonoBehaviour{public GameObject birdPrefab;public float interval=0.3f;float time=0f;// Start is called before the first frame updatevoid Start(){}// Update is called once per framevoid Update(){time+=Time.deltaTime;if(time>interval){Instantiate(birdPrefab,new Vector3(transform.position.x,Random.Range(3.25f,4.29f),0f),Quaternion.identity);time=0;}}}
using System.Collections;using System.Collections.Generic;using UnityEngine;public class bird : MonoBehaviour{public float speed=3.5f;// Start is called before the first frame updatevoid Start(){}// Update is called once per framevoid Update(){transform.position-=new Vector3(speed*Time.deltaTime,0f,0f);}}
using System.Collections;using System.Collections.Generic;using UnityEngine;public class bullets : MonoBehaviour{public static bullets instance; // Creating a singleton patternprivate void Awake() {instance=this;}private float speed=4f;// Start is called before the first frame updatevoid Start(){}// Update is called once per framevoid Update(){transform.position+=new Vector3(0f,speed*Time.deltaTime,0f);}public void OnTriggerEnter2D(Collider2D other) {if(other.tag=="Bird"){print("Bird encountered");gameObject.SetActive(false);other.gameObject.SetActive(false);}}}

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Cleaning out secrets from git repositories

Learning Python 3 The Hard Way — (Exercise 11–20)

Write your Rugs in Python

Remove Terraform resources selectively :

Awesome Python projects you can build in an hour

Managing digital files — for your college or university. | Daminion Blog

Reduce Cost and Increase Productivity with Value Added IT Services from buzinessware — {link} -

Reduce Cost and Increase Productivity with Value Added IT Services from buzinessware — {link} -

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nilay Paul

Nilay Paul

More from Medium

To pull the trigger or not pull the trigger, that is the collision.

Scaling Bar HUD for Thrusters

Understanding Big O

How do Coroutines Work in Unity?