Here is the situation. I have a bullet prefab that alters the movement speed of any object with a certain tag. But all the enemies have different movement scripts attached to them. I have the speed variable named exactly the same on every enemy movement script.
so my question is, is there a way for my bullet prefab to look for a particular variable on a gameobject, without Getcomponent. The Reasoning is that i do not want my bullets prefab script to have to run through countless if statements on a collision to find the correct enemy movement script to access the speed variable.
In a perfect case I would like to say something like,
OnCollisionEnter(Collision other)
{
if(other.tag == “Something”)
{
“get access to the the speed variable of the other gameobject”
}
}