Help With GetComponent with a Collision Object

I am trying to access a value inside the object I collided with.
I have searched Google and I have tried various things.
This is what I have now, GetValue is just a public int Getter inside Walker:

2 Likes

Hello Retro,

What is the name of the walker’s script with the GetValue public int?? is it GetValue?

1 Like

Yes it is called GetValue()

2 Likes

but the script? the MonoBehaviour?

1 Like

Here is the Script trying to access Walker.GetValue()

And the Script that has GetValue() in it:

1 Like

you should be using:

walker = col.gameObject.GetComponent<Walker>();
TMP = walker.GetValue();
planeShoot.AdjustScore(TMP);

GetValue is the method inside “Walker” MonoBehaviour, GetComponent should be used to access the script in order to TMP access the GetValue()

1 Like

it worked? :confused:

1 Like

Thank you @Joao_Dalvi it is working.

2 Likes

Awesome!! :grinning:

1 Like