Editing a variable in another script during runtime
Hi community! I have a "mover" attached to my "obstacle"-Prefab which moves these spawned objects with "AddForce". Now i want to increase the speed of these obstacles for each spawned obstacle during runtime. How can i access the public variable "speed" of the "mover"-Script with my "Game Controller"-Script?
To properly help you you should really post both scripts (the script that spawns your prefabs and the script attached to your prefab).
Answer by Sayalec · May 09, 2016 at 07:42 PM
Thanks to you guys! I found the solution! Here is what helped me:
var target : GameObject;
function InitProjectile() { var newProjectile : Projectile = Instantiate(porjectilePrefab,position,rotation); var otherScript : newProjectile.GetComponenet.(); target = otherScript.victim; }
Your answer
Follow this Question
Related Questions
Rotate Player 90 degrees about its Y axis relative to the mouse being dragged between two angles 1 Answer
Cant add script becuase of error 2 Answers
2D ROGUELIKE SCRIPTING HELP , 2D Roguelike Script issues 1 Answer
How to make my live2D character always look at cursor? 0 Answers
Animate instantiated object via C# 2 Answers