Example #1
0
 public void unlockTarget()
 {
     if (state == SnapTargetState.Locked)
     {
         state = SnapTargetState.Closed;
     }
 }
Example #2
0
    public void disconnect()
    {
        state    = state == SnapTargetState.Holding? state : SnapTargetState.Open;
        dist     = null;
        timeLasp = 0.0f;

        resetPhysic();

        playAudioEffect(unlockSound);
    }
Example #3
0
    public void snapTo(Transform d)
    {
        if (d == null || state != SnapTargetState.Open)
        {
            return;
        }
        dist = d;

        clearPhysic();

        state = SnapTargetState.Moving;
    }
Example #4
0
    // FixedUpdate is not called every graphical frame but rather every physics frame
    void FixedUpdate()
    {
        if (state == SnapTargetState.Moving && timeLasp / speed <= 1.0f)
        {
            timeLasp += Time.deltaTime;

            if (timeLasp >= speed)
            {
                state    = SnapTargetState.Closed;
                timeLasp = 0.0f;
                playAudioEffect(lockSound);
            }
            gameObject.transform.position = Vector3.Lerp(gameObject.transform.position, dist.transform.position, timeLasp / speed);
            gameObject.transform.rotation = dist.transform.rotation;
        }
    }
Example #5
0
 public void setState(SnapTargetState s)
 {
     state = s;
 }