- Home /
Question by
ckho92 · Dec 21, 2016 at 07:37 AM ·
gameobjectscript.variable
How to create gameobject with different setting
I would like to create an object call enemy by using another object call enemySpawner
the property of enemy are:
public float movingSpeed;
and i would like to use enemySpawner to spawn the object enemy with different moving speed.
How can I do this as each enemy have different moving speed? Thank you.
Comment
Best Answer
Answer by GrKl · Dec 21, 2016 at 07:43 AM
GameObject newEnemy = Instantiate(enemyPrefab, newPosition, Quaternion.Identity) as GameObject;
newEnemy.GetComponenet<EnemyScript>().movingSpeed = theSpeedYouWant;
Your answer
Follow this Question
Related Questions
How to access a game object from a different scene? 0 Answers
Calculating Scrolling GameObject x position scrolling pass another GameObject x postion (2D Game) 1 Answer
How do I play gameobjects in my scene from one script / Script is not working 0 Answers
How can i access in a prefab a variable from a gameObject? 1 Answer
How would I be able to subtract from a variable when it hits something? (OnCollisionEnter) 1 Answer