help with the shared gameobject

My game have different types of enemy, and each one has a different script attached to control their behavior, but they use some of the same thing like bullet or deadFX, my question is which is the best way to access these shared gameobject variables?

Do I need to create the same variables in each of the enemy behavior script like:

var bullet : GameObject;
var deadFx : GameObject;
//...etc

or just create them in one public script, and all the other script can access these variables.

Does anyone can show me the example? Thanks a lot.

Derive from a base class which has all the defaults.

example:

EnemyBase.js

public var bullet : GameObject;
public var deafFX: GameObject;
//etc etc

and your different enemies derive from it

SomeEnemy.js

class SomeEnemy extends EnemyBase{
var enemySpecificVar : GameObject;
//etc
}

:slight_smile:

Thank you for your help, I’ll try it:p