Hello. I know this question is kinda basic, but searching through the internet I can’t really seem to find an answer. What I want, is to grab a variable from a public method (“public void FireBullet()”) in another script from another gameObject. Without the variable being set outside of the method. Because I know that i can access these variables like this: Derp d = (Derp)GetComponent("Derp");
So a visual example of what I want kinda looks like this:
Derp d = (Derp)GetComponent("Derp")
//this is what my brain is thinking (syntactical facepalm, though):
hpLost = d.FireBullet().damageDealt
Any enlightenment here would be greatly appreciated. I’ve stumbled across this before, and I just had to resort to finding a way to use it as a public variable outside of the method, but it seems like overwork, the list of public variables outside of the methods will get very big.