B
B
BadCats2016-11-30 23:25:53
C++ / C#
BadCats, 2016-11-30 23:25:53

Typecasting in Unity3d using c#?

convert type "UnityEngine.CollisionFlags" to "UnityEngine.Vector3". - it is generally real from the point of view of ghosts of types?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Daniil Basmanov, 2016-12-01
@BadCats

You cannot cast CollisionFlags in Vector3, but you can write your own transformation method, though it will turn out to be nonsense.

private Vector3 GetVector3(CollisionFlags flags)
{
    switch (flags)
    {
        case CollisionFlags.None:
            return Vector3.zero;
        case CollisionFlags.Above:
            return Vector3.up;
        case CollisionFlags.Below:
            return Vector3.down;
        case CollisionFlags.Sides:
        default:
            return Vector3.zero;
    }
}

G
GavriKos, 2016-11-30
@GavriKos

If there is a corresponding overloaded cast operator, then it's real. But something I doubt - from the point of view of logic. What are you trying to do?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question