The Bullet class

Next, we set up our Bullet prefab with two orthogonal planes using a laser-like material and a Particles/Additive property in the Shader field:

Our Bullet prefab

The code in the Bullet.cs file is as follows:

using UnityEngine; 
using System.Collections; 
 
public class Bullet : MonoBehaviour 
{ 
    //Explosion Effect    [SerializeField]
    private GameObject Explosion;     [SerializeField]    private float Speed = 600.0f;    [SerializeField]    private float LifeTime = 3.0f;      public int damage = 50; void Start() { Destroy(gameObject, LifeTime); } void Update() { transform.position += transform.forward * Speed * Time.deltaTime; } void OnCollisionEnter(Collision ...

Get Unity Artificial Intelligence Programming - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.