Home Game Development unity – How can I detect whether or not a degree is transferring in a circle?

unity – How can I detect whether or not a degree is transferring in a circle?

0
unity – How can I detect whether or not a degree is transferring in a circle?

[ad_1]

I need to detect if my GameObject (Vector3 Point) being dragged by the participant’s finger is transferring in a round style.

I assumed I may save the final 5 factors each 10 frames and
be part of them by traces. Then I’d challenge them right into a “outlined” aircraft. From there, I can kind the perpendicular bisectors of these line segments – to verify the place they’re intersecting.

If each intersection level could be very close by – the finger is swiping in a circle!

Diagram of proposed strategy using perpendicular bisectors

Now I solely have to verify if the intersection level is shut.

How can I verify in the event that they intersect? Or is there a greater technique to clear up this?

Here’s my code thus far:

public LinkedList<Vector3> FingertipPoints;
public Transform Fingertip;

non-public void Start()
{
    FingertipPoints = new LinkedList<Vector3>();

    FingertipPoints.AddFirst(new Vector3(0, 0, 0));
    FingertipPoints.AddLast(new Vector3(0, 0, 0));
    FingertipPoints.AddLast(new Vector3(0, 0, 0));
    FingertipPoints.AddLast(new Vector3(0, 0, 0));
    FingertipPoints.AddLast(new Vector3(0, 0, 0));
}

[Range(1,60)]
public int FramesPerCheck = 10; // 6checks per sec
non-public int Frame;
// Update is known as as soon as per body
void LateUpdate()
{
    Frame++;
    if (FramesPerCheck == Frame)
    {
        Frame = 0;
        FingertipPoints.Take awayLast();
        FingertipPoints.AddFirst(Fingertip.place);
    }

    //Get the Direction Vectors
    Vector3 V1 = FingertipPoints.First.Value - FingertipPoints.First.Next.Value;
    Vector3 V2 = FingertipPoints.First.Next.Value - FingertipPoints.First.Next.Next.Value;
    Vector3 V3 = FingertipPoints.First.Next.Next.Value - FingertipPoints.First.Next.Next.Next.Value;
    Vector3 V4 = FingertipPoints.First.Next.Next.Next.Value - FingertipPoints.Last.Value;

    //Project them on a aircraft
    V1 = Vector3.ProjectOnPlane(V1, Fingertip.ahead);
    V2 = Vector3.ProjectOnPlane(V2, Fingertip.ahead);
    V3 = Vector3.ProjectOnPlane(V3, Fingertip.ahead);
    V4 = Vector3.ProjectOnPlane(V4, Fingertip.ahead);

    //Get the Perpendicular Vectors (is that this even proper?)
    Vector3 C1 = Vector3.Cross(V1, Fingertip.ahead);
    Vector3 C2 = Vector3.Cross(V1, Fingertip.ahead);
    Vector3 C3 = Vector3.Cross(V1, Fingertip.ahead);
    Vector3 C4 = Vector3.Cross(V1, Fingertip.ahead);

    //???
    //How to verify in the event that they intersect close by??
    //

}

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here