protected virtual void FixedUpdate() { if (doLookAt == true) { myLookAtProcess += Time.fixedDeltaTime * myLookAtSpeed; // stop if (myLookAtProcess >= 1) { myLookAtProcess = 1; doLookAt = false; } // get position Vector3 t_targetPosition = Vector3.zero; if (myLookAtTarget != null) { t_targetPosition = myLookAtTarget.transform.position; } t_targetPosition.z = 0; // move this.transform.position = Vector3.Lerp(this.transform.position, t_targetPosition, myLookAtProcess); // scale float t_size = 6; if (myLookAtTarget != null) { t_size = Mathf.Abs(myLookAtTarget.GetRadius()) + 1; } myCamera.orthographicSize = Mathf.Lerp(myCamera.orthographicSize, t_size, myLookAtProcess); } else { if (myLookAtTarget == null) { this.transform.position = Vector3.zero; } else { this.transform.position = myLookAtTarget.transform.position; myCamera.orthographicSize = Mathf.Abs(myLookAtTarget.GetRadius()) + 1; } } }
public void UpdateRadius() { // lerp multiplier Update_LerpRadiusMultiplier(); if (myParent != null) { myRadius = myMultiplier_Radius * myParent.GetRadius(); // update position float t_posX = myParent.GetRadius() - myRadius; this.transform.localPosition = Vector3.right * t_posX - Vector3.forward; } else { myRadius = myMultiplier_Radius; // update position this.transform.localPosition = -Vector3.forward; } // set size myTransform_Display.localScale = new Vector3(myRadius * 2, myRadius * 2, 1); myCollider.radius = Mathf.Abs(myRadius); }
/// <summary> /// /// </summary> /// <param name="g_spot">a spot to store smaller planet</param> /// <param name="g_target">planet to compare with</param> /// <returns>the larger planet</returns> private CS_Planet FillMinSizePlanet(ref CS_Planet g_spot, CS_Planet g_target) { if (g_target == null) { return(null); } CS_Planet t_origin = g_spot; if (t_origin == null) { g_spot = g_target; return(null); } if (t_origin.GetRadius() > g_target.GetRadius()) { g_spot = g_target; return(t_origin); } return(g_target); }