Reputation:
I have a problem with my update function. I have a class called HydraBehaviour
for my Hydra Enemy in my game. And the HydraBehaviour
inherits from the EnemyBehaviourClass
which is a class with a update method to ChasePlay();
and StopChasingPlayer();
.
In my Hydra class I want to create the attack System, because not all Enemies will have the same time attacking style. And so my problem is that I can't use the update method in Hydra Class, because it's already used in the EnemyBehaviourClass
. So I'm forced to use Fixed Update but that's not the way to go.
Upvotes: 2
Views: 76
Reputation: 124
You can have an update function in your HydraBehaviour and call the update function in EnemyBehaviourClass.
public class HydraBehaviour : EnemyBehaviourClass
{
void Update()
{
base.Update();
// Your Hydra specific code goes here
}
}
Just make sure your Update function in EnemyBehaviourClass is either public or protected. This will not work if the function is private.
Upvotes: 5