How Do I Use GetType? What Is it?

I found out in a forum that I need GetType to find the script for my object, which i am using as a character.
i got the camera for the character, now i am adding a move asset to it, I kept getting errors about my script and I need to find it for the object… Please help! thanks,
Isaac

You should probably post the script, along with the errors.

I thing you’ve been mislead. GetType is part of reflection. And you normally only need reflection if you want to do tricky things with converting between strings and code, or reading code you don’t have access to, or other similar nonsense.

1 Like

@Kiwasi how do I find the script I need then?

how do i add the object to the script?

Maybe start here.

GetType is part of the C# reflection API. Honestly there’s very little you should need from the reflection C# in gamedev, if you find yourself using it you should ask yourself if you really need to be using reflection.

A better way to ask this question is explain what you’re trying to do, how you’re trying to accomplish and post any code you’ve written thus far. I don’t know what you’re trying to do, but I can almost guarantee you there’s a better way than using GetType.

2 Likes

I genuinely have no idea what you are trying to do.

But for general script to script communication, here is a video I made.

https://www.youtube.com/watch?v=iO5ADWj9g3Y

1 Like

I think you’re meaning GetComponent, not GetType.

That gets the script component from the game object.