Hi everybody. I’m having problems working with subclasses, like the next example:
I have those scripts:
.-A controller script (_thugController.cs) that manages the movement of enemies and variables (speed, jump, etc.).
.-A subclass controller script (_flyController.cs) for aereal enemies.
.-An action script (_flyActions.cs).
My “flyController.cs” script has their own variables, like ex.:
using UnityEngine;
using System.Collections;
public class _flyController : _thugController {
public Vector3 trajectory;
public float accel;
public float deccel;
void Start () {
base.VarStart();
}
}
And I need “_thugActions.cs” get those variables:
public class _flyActions : _thugActions {
public enum eneState{Patrol, Attack, Stop};
public eneState state;
public _thugController thugCon; //Used to access _flyController.cs
// Use this for initialization
void Start () {
base.VarStart();
state = eneState.Patrol;
thugCon.accel = 4f;
thugCon.deccel = 15f;
}
}
But then, the script can’t get both “accel” and “deccel” because “thugCon” is being read like the Main Class, and not like the “fly” SubClass.
Is there any solution other than creating a “_flyController.cs” variable?