public void unlockTarget() { if (state == SnapTargetState.Locked) { state = SnapTargetState.Closed; } }
public void disconnect() { state = state == SnapTargetState.Holding? state : SnapTargetState.Open; dist = null; timeLasp = 0.0f; resetPhysic(); playAudioEffect(unlockSound); }
public void snapTo(Transform d) { if (d == null || state != SnapTargetState.Open) { return; } dist = d; clearPhysic(); state = SnapTargetState.Moving; }
// 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; } }
public void setState(SnapTargetState s) { state = s; }