Hey guys,
would love some help with this issue.
I have my base properties class which contains bot properties.
using UnityEngine;
using System.Collections;
// Bot Properties
public class Bot : MonoBehaviour {
public float health; // Health of bot
public float moveSpeed; // Moving speed of bot
public float turnSpeed; // Turning speed of bot
public float AmmoCrateDropRate; // The bots chance to drop ammo crate on death
public AmmoData [] ammoDrops; // List of possible ammo drops
}
Below is the controller class for a basic bot.
using UnityEngine;
using System.Collections;
// Handles Bot behaviour
public class BotController : MonoBehaviour {
public Bot bot; // Bot details
// State "DYING"
// Has taken damage equal or greater then its health
// and has been killed
protected override void DyingState() {
// Do death animation
// Destroy self
}
...
}
Below is my derived properties class
using UnityEngine;
using System.Collections;
public class Bot_ZombieExplodingGrunt : Bot {
public float explosionDamage;
public float explosionRadius;
}
// Below is my derived bot controller class
using UnityEngine;
using System.Collections;
public class BotController_ZombieExplodingGrunt : BotController {
public new Bot_ZombieExplodingGrunt bot;
// State "DYING"
// Has taken damage equal or greater then its health
// and has been killed
protected override void DyingState() {
// Do explosion on death
Physics.OverlapSphere(obj.position, bot.explosionRadius);
base.DyingState();
}
}
Most bots will run fine on the base class, but I want a few to have additional behaviour. The code compiles fine in monodeveloper, but in unity it gives me this error.
Same name multiple times included:::Base(MonoBehaviour) bot
The issue is that my bot now has two bot fields showing up in the inspector.
caused by this: public new Bot_ZombieExplodingGrunt bot;
the issue remains with and without the “new”
How is the correct way of doing inheritance in c#?
Help would be appreciated, I have spent hours trying different things, searching through C# examples and unity forums.
I know I could properly just do “public Bot_ZombieExplodingGrunt explodingBot” or something in the derived controller class, but I was hoping for a neater method.
Thanks!
Edit: I also tried to use casting, but it didn’t seem to work.
Edit: Also this is for iOS devices.