So I’m hoping there’s an easier way to do this, without adding things that don’t need to exist.
I have bullet prefabs that will all have a different script with the qualities the bullets have. prefab can be assigned when changing weapons, etc, problem is, i want to get my AI’s to lead targets a reasonable amount, and to do that, i need to get the speed from the prefab.
unless a prefab was already instantiated, i can’t seem to get the variable, regardless of setting it in it’s base, or in Start(). the
Debug.Log (shot.GetComponent<BlueBullet>().speed); just puts out 0 until i instantiate one. technically fine, though irritating, since the first shot wouldn’t be with a lead. i could just instantiate a shot of the type on scene load, but that seems dirty. i could also attach the script to it, by having the base script attached to the core object, but addcomponent could get grueling with hundreds of shots.
so i guess the question is, can i actually access a variable from a script that hasn’t shown up in a scene, or do i need to find a different way of assigning attributes to bullets, instead of a script on a prefab?
that may in fact be another good question, can i assign values based on the equipped gun to a “blank” script on a prefabbed shot?