I am having problems calling MonoBehaviour method such as OnCollisionEnter.
start with
public class PowerUp : MonoBehaviour
{
void OnCollisionEnter (Collision collisionInfo)
{
Debug.Log("PowerUp");
}
}
this works fine but
public class Strong : PowerUp
{
void OnCollisionEnter (Collision collisionInfo)
{
Debug.Log("Strong");
}
}
when I put Strong on an object PowerUp’s method get called not Strong’s (hiding does not seem to work) I can’t override OnCollisionEnter because it is not virtual in MonoBehaviour. I end up doing this which is ugly
public class PowerUp : MonoBehaviour
{
void OnCollisionEnter (Collision collisionInfo)
{
XOnCollisionEnter (collisionInfo);
}
virtual void XOnCollisionEnter (Collision collisionInfo)
{
Debug.Log("PowerUp");
}
}
public class Strong : PowerUp
{
override void XOnCollisionEnter (Collision collisionInfo)
{
Debug.Log("Strong");
}
}
does anyone have a more elegant solution?