Typecast a Generic T in Vector3

Hi there!

I started using Generics for the first time, and I got an issue.

here an example of my function :

void test<T>( T parTarget)
{
  if (parTarget as Vector3)
        Vector3 TempTarget = parTarget as Vector3;
}

As you probably know, I cant use as Vector3 as Vector3 is a structure. I searched around the web for an answer, but didn’t find anything for my specific case.

If you have an idea, go for it! :slight_smile:

As the word “generic” suggests, you shouldn’t go into type specifics inside such methods. I don’t know if your method is more complex than what you’re showing and what it’s supposed to do, but whatever it does, it usually does it for a bunch of different types, not just a Vector3. In your case better write the method explicitly for Vector3s.