private void MoveTo(Vector3 toPoint, float speed) { if (pathSpeedModifier.ToString() == "ConsistentSpeed") { currentLift.localPosition = Vector3.MoveTowards(currentLift.localPosition, toPoint, speed * Time.deltaTime); } else if (pathSpeedModifier.ToString() == "SplitSpeed") { currentLift.localPosition = Vector3.MoveTowards(currentLift.localPosition, toPoint, speed * Time.deltaTime); } }
private void Update() { // Bubble return to default path when no players are inside if (bubbleMoveInt == 0) { if (transform.position.x == startPos.x) { isMovingLeft = false; } else if (transform.position.x < targetPos.x) { isMovingLeft = true; } else { isMovingLeft = false; } if (transform.position.y == startPos.y) { isMovingUp = false; } else if (transform.position.y > targetPos.y) { isMovingUp = true; } else { isMovingUp = false; } if (pathSpeedModifier.ToString() == "ConsistentSpeed") { currentBubble.localPosition = Vector3.MoveTowards(currentBubble.localPosition, posA, consistentSpeed * Time.deltaTime); } else if (pathSpeedModifier.ToString() == "SplitSpeed") { currentBubble.localPosition = Vector3.MoveTowards(currentBubble.localPosition, posA, splitBackwardsSpeed * Time.deltaTime); } } //// bubbleMoveInt == 1 is set to player "Night" and will freeze the bubble to place //if (bubbleMoveInt > 0) //{ // childCollider.enabled = true; //} //else //{ // childCollider.enabled = false; //} // Bubble starts moving when player "Day" is inside if (bubbleMoveInt == 2) { if (transform.position.x == startPos.x) { isMovingLeft = false; } else if (transform.position.x < startPos.x) { isMovingLeft = true; } else { isMovingLeft = false; } if (transform.position.y == startPos.y) { isMovingUp = false; } else if (transform.position.y > startPos.y) { isMovingUp = true; } else { isMovingUp = false; } if (pathSpeedModifier.ToString() == "ConsistentSpeed") { currentBubble.localPosition = Vector3.MoveTowards(currentBubble.localPosition, endPos, consistentSpeed * Time.deltaTime); } else if (pathSpeedModifier.ToString() == "SplitSpeed") { currentBubble.localPosition = Vector3.MoveTowards(currentBubble.localPosition, endPos, splitForwardSpeed * Time.deltaTime); } } if (isMovingLeft && !behindOn) { behindParticle.Play(); behindOn = true; } else if (!isMovingLeft) { behindParticle.Stop(); behindOn = false; } if (isMovingUp && !belowOn) { belowParticle.Play(); belowOn = true; } else if (!isMovingUp) { belowParticle.Stop(); belowOn = false; } }