C# Inheritance Question

I need some help setting up an abstract class. Im confused about class variables and how they inherit, if they even do. Spawntime is being treated as a variable shared by all subclasses. Also, is it possible for the child classes to extend on the abstract classes Update() method? Here is the Abstract Class code I have now:

public abstract class  AbstractProjectile : MonoBehaviour {


    public bool DestroyOnTimer = false;
    public bool DestroyWhenInvisible = true;
    public float TimeToLiveInSeconds = 1.0f;

    
    //Time the Projectile was created
    private float spawnTime;

	// Use this for initialization
	void Start () 
    {
        spawnTime = Time.time;            
	}
	
	// Update is called once per frame
	void Update () 
    {            
        //Destroy the projectile if its timer is over
        if (DestroyOnTimer)            {
            
            if ((Time.time - spawnTime) > TimeToLiveInSeconds)
            {
                Destroy(gameObject);
            }        
        }
        //Call Child projectiles move method
        move();
	}

    public virtual void move() { }
  }

Here is the Child Code:

using UnityEngine;
using System.Collections;

public class SinBulletScript : AbstractProjectile {

    public float speed = 1000.0f;
    public float Amplitude = 600.0f;
    public float Omega = 15.0f;


	// Use this for initialization
	void Start () 
    {
        Vector3 shipPosition = GameObject.Find("Ship").transform.position;
        shipPosition.y += 100;
        transform.position = shipPosition;
            
	    
	}
		

    void move()
    {
        gameObject.rigidbody.velocity = new Vector3(Amplitude * Mathf.Sin(Time.time * Omega), speed, 0);
    }
}

I only see one question: “is it possible for the child classes to extend on the abstract classes Update() method?”, so I’ll answer that.

The answer is no. Update is a method that has special meaning to Unity - you can think of it as reserved. You can’t redefine Update as abstract. Unity will call your Update function, but you can certainly define another function that gets called from Update - say myUpdate - and do whatever you want with it.

As for your variable question. It’s confusing, but private variables are not accesible by children. You need to take a look at the protected keyword, which are variables your children will have access to. I believe this keyword is unique to C#, so if you are coming from other languages, it is probably confusing.