GetComponent returning new component

Hey,

I’m trying to use

ScriptA script = GetComponent<ScriptA>();
script.Test()

However, it appears that GetComponent is returning a new, blank version of ScriptA, not the one that has been modified. All the variables at their default values, and modifying any has no effect on the actual ScriptA component being executed.

Anything that I am doing wrong?

Thanks

You’ll need to show more code than that. Do you have more than one ScriptA on the gameobject?

Yeah, GetComponent<>() returns null if there isn’t a Component of the specified type on the GameObject. I also suspect that you’ve got more than one matching Component.

EDIT: Just saw I have two attached. Didn’t think that could happen. Thanks

What’s your Gravity value, and is there possibly anything else which could be messing with it?

Everything work well now thanks.