Completed Game Files

Bullet behavior

This is attached to the Bullet prefab, as follows:

using System.Collections;using System.Collections.Generic;using UnityEngine;public class BulletBehavior : MonoBehaviour {    public float onscreenDelay = 5f;    void Update ()     {        Destroy(this.gameObject, onscreenDelay);    }}

Camera behavior

This is attached to the Main Camera object, as follows:

using System.Collections;using System.Collections.Generic;using UnityEngine;public class CameraBehavior : MonoBehaviour {    public Vector3 offset;    private Transform playerPos;    void Start()    {        playerPos = GameObject.Find("Player").transform;    }    void LateUpdate()    {        this.transform.position = playerPos.TransformPoint(offset);        this.transform.LookAt(playerPos);    }}

Enemy behavior ...

Get Learning C# by Developing Games with Unity 2019 - 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.