protected void StartMoveTo(Vector3 targetPos) { SendMessageUpwards("PlayObstacleSound", obstacleManager.GetSoundVolume(gameplayManager.Level) * 0.01f, SendMessageOptions.DontRequireReceiver); movingTimer = TimeManager.Instance.MasterSource.TotalTime; float mult = 1.0f - Mathf.Min(1.0f, ((initialPos - targetPos).magnitude * 0.1f)) * 0.5f; movingDuration = Random.Range(2.0f, 5.0f) * mult; Transform childTr = animChild.transform; initialPos = new Vector3(childTr.position.x, childTr.position.y, childTr.position.z); initialRot = new Quaternion(childTr.rotation.x, childTr.rotation.y, childTr.rotation.z, childTr.rotation.w); distance = Mathf.Min((targetPos - initialPos).magnitude, ObstaclesManager.ObstacleOccupation * 0.5f); direction = (targetPos - initialPos); direction.y = 0.0f; direction.Normalize(); targetRotAngle = Random.Range(-90.0f, 90.0f); damp = 0.0f; if (gameplayManager.Level == 0) { distance = ObstaclesManager.ObstacleOccupation * 0.5f; direction = Vector3.right; movingDuration = 4.0f; } }