public void PickUp(SpyBallAnchor holdAnchor) { if (isHeld && holdAnchor.hand == currentHand) { return; } else if (isHeld && holdAnchor.hand != currentHand) { currentHand = holdAnchor.hand; transform.SetParent(holdAnchor.transform); transform.localPosition = Vector3.zero; throwArc = new List <ThrowArcStep>(); lastPosition = transform.position; } else { currentHand = holdAnchor.hand; ballRigidBody.isKinematic = true; ballCollider.isTrigger = true; transform.SetParent(holdAnchor.transform); transform.localPosition = Vector3.zero; ballRigidBody.velocity = Vector3.zero; throwArc = new List <ThrowArcStep>(); isHeld = true; lastPosition = transform.position; ChangeColor(validColor); } }
public void Drop(SpyBallAnchor holdAnchor) { if (!CheckThrowValidity() || holdAnchor.hand != currentHand) { return; } ballRigidBody.isKinematic = false; ballCollider.isTrigger = false; transform.SetParent(null); isHeld = false; currentHand = SpyBallAnchor.Hand.none; ballRigidBody.velocity = GetThrowVelocity(); throwArc = new List <ThrowArcStep>(); isStopped = false; ChangeColor(movingColor); }
public void Teleport(SpyBallAnchor ballAnchor) { if (spyBall == null || head == null) { Debug.LogError("TeleportToSpyBall: References not set!"); return; } if (spyBall.isHeld || !spyBall.isStopped || !spyBall.validPosition) { return; } Vector3 distToHead = head.position - transform.position; Vector3 distToPlayer = new Vector3(distToHead.x, 0f, distToHead.z); transform.position = (spyBall.transform.position - Vector3.down * spyBall.ballRadius) - distToPlayer; if (backToHandOnTeleport) { spyBall.PickUp(ballAnchor); } if (teleportParticlePrefab != null) { Instantiate(teleportParticlePrefab, transform.position + distToPlayer, Quaternion.identity); } }