|
Hi Everyone, I've been trying for a while now to figure this out but I'm stumped. I'm trying to instantiate a group of objects each with random values for certain properties (Ex. larger scale, faster move speed, etc). This script works for the most part but the values only get increased on the original object, not any of the instances. If I run this script as is, I get a NullReferenceExpection error. The issue is how to access the variables in instanced objects individually, rather than globally. The "moveForward" script is attached to every enemy object, this script controls the speed the object moves at. It will eventually be updated to include health, armor and scale. All of which should be randomly generated. The moveForward script contains a variable called moveSpeed. This line is causing the problem I think. Instead of modifying the moveSpeed variable of each instance, it modifies the variable of the original object only. This value keeps going up and up with each new object instantiated. The instances are unchanged. Full script without comments:
(comments are locked)
|
|
Something like this: That worked perfectly, and the best part is I understand what's going on. Thank you!
Oct 19 '11 at 01:27 AM
OtsegoDoom
This doesn't work. I get the error : 'GetComponent' is not a member of UnityEngine.Object So how did this ever work - if 'Instantiate' returns a Object not a GameObject!?
Mar 30 '12 at 08:28 AM
zv_odd
(comments are locked)
|
