Hi,
would like to code common behaviour for bullets, like timed life.
So i created a superclass and gave it all it needs to know.
Then i made a subclass and tried to bring things to work…
Somehow i try to change here and there but in the end i just gain a lot of errors.
Here is the Code.
SuperClass:
using UnityEngine;
using System.Collections;
public class TimedLifeObject : MonoBehaviour {
private float lifetime_Limit;
private float lifetime_Timer;
// Use this for initialization
void Start () {
lifetime_Limit = 1;
lifetime_Timer = 0;
}
// Update is called once per frame
void Update () {
lifetime_Timer += Time.deltaTime;
if (lifetime_Timer >= lifetime_Limit)
Destroy(this);
}
public float lifetime_Max {
get { return lifetime_Limit;}
set { lifetime_Limit = value; }
}
public float lifetime_Left {
get { return lifetime_Timer; }
}
}
SubClass:
using UnityEngine;
using System.Collections;
public class BulletBehaviour : TimedLifeObject {
// Use this for initialization
public void Start () {
lifetime_Max = 5F;
}
// Update is called once per frame
void Update () {
base.Update();
transform.Translate(+.1F,0,0, Space.World);
}
}
I appriciate any help.
greets