Cast to drone seems redundant :)

Casting to the drone seems like it would be less versatile, as if any other enemies are added in the future, they would also need to be casted to. So why cast at all, since we’re not calling a function on the drone anymore?

*yes I saw the other post, but it was locked

Hello Via, apologies for the late reply.

You’re absolutely right! If we are not accessing anything that’s specifically in the Drone class then we do not need to cast for it.

And ideally, for larger games, we’d make a base enemy class or use an interface to access enemy functions regardless of what enemy that’s being hit. Though since this is a small project we can get away with just casting to the Drone.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms