Hi,
I have a problem with the inheritance in my project.
I have a script named DynamicEntityScript.
I also have the playerScript with heritate from the DynamicEntityScript
public class PlayerScript : DynamicEntityScript, IDataPersistence
The DynamicEntityClass has a public attribut DynamicEntityData
public class DynamicEntityScript : MonoBehaviour
{
public DynamicEntityData dynamicEntityData;
}
On the same model the player Script has a PlayerEntityData wich inheritate from DynamicEntityData.
public class PlayerScript : DynamicEntityScript, IDataPersistence
{
public PlayerEntityData playerEntityData;
}
public class PlayerEntityData : DynamicEntityData
I have a problem I canât solve.
I create a script wich is suppose to be attached to every dynamicEntity.
So I attached it to ânaturalâ dynamicEntity and to my player.
This script look for DynamicEntityScript attached and in both case it find one.
entityScript = this.gameObject.GetComponent<DynamicEntityScript>();
In the case of the player it foud it as a PlayerSCript but I canât acces to the playerEntityData with.

entityScript is a PlayerSCript, and this player Script as a playerEntityData :
wich as some Data :
but when I look on the dynamicEntityData, the system find out itâs a playerEntityData:
but there is no Data :
so I tested to use this Entity as a player :
if (entityScript is PlayerScript)
{
PlayerScript scriptTest = entityScript as PlayerScript;
scriptTest.playerEntityData.refreshData();
}
else
{
entityScript.dynamicEntityData.refreshData();
}
in the case I force the entityScript as a playerScript it work but I donât understand why I canât jsut manipulate my playerSCript as a DynamicEntitySCript.
I donât want to have one script for the player and another for dynamicEntity.
Any Idea why i have this problem?
Thanks for your help.



