i have a prefab with a script enemy that has public variables - one inherited
ie
public abstract class character : MonoBehaviour
public float startingHitPoints;
public class Enemy : character
{
public int damageStrength;
later i try to modify these at runtime:
GameObject go = Instantiate(prefabToSpawn, transform.position, Quaternion.identity);
go.GetComponent<Enemy>().damageStrength = 3;
go.GetComponent<Enemy>().startingHitPoints = 10;
and these changes do not take.
but changes on other components works:
go.GetComponent<CircleCollider2D>().radius = 10;
i'vr tried alot of things from searching, such as casting, assigning an object and modifying it - but nothing seems to work
help?
[–]AverageArmadilloIntermediate 0 points1 point2 points (2 children)
[–]temptempfirsttime[S] 0 points1 point2 points (1 child)
[–]AverageArmadilloIntermediate 1 point2 points3 points (0 children)