Hi,
I would like to clarify the uses of inheritance class and static properties before I encounter a problem.
My game is a boat game with several levels. On those levels there is 2 differents kind of water : deep water and shallow water. One level will have a deep water or a shallow water, never both. To create them this is what I have done :
- One parent class Water (inherited from MonoBehaviour) that contains every attributes common to all waters (mesh and mesh data mostly)
- One class DeepWater (inherited from Water) with function and attributes dedicated for this kind of water
- One class ShallowWater (inherited from Water) with function and attributes dedicated for this kind of water
Up to here I think everything is OK.
The trick is that all the attribute in Water are static. They are all defined in awake by either DeepWater or ShallowWater.
I did that so every object can access basic variables without looking for a special instance. For example, the ship acces the mesh (which is a static property of Water) simply with Water.mesh. I will use this code no matter if the water is deep or shallow.
Will it work ?
I’m pretty new to object oriented programming, so please don’t mind saying obvious things ![]()