private void OnEnable() { Vector3 targetLocation = _grid.GetRandomTile(false).Position; Vector3 direction = Quaternion.Euler(0.0f, Random.Range(20.0f, 160.0f), 0.0f) * Vector3.right; _transform.position = new Vector3(targetLocation.x, Random.Range(5.0f, 7.0f), targetLocation.z) - (direction * 20.0f); _rigidbody.velocity = direction * Random.Range(2.0f, 5.0f); _soundEffect.volume = 0.0f; _isExiting = false; }
private void OnEnable() { _destinationTile = _playingFieldGrid.GetRandomTile(true); if (_destinationTile == null) { gameObject.SetActive(false); return; } _scale = 0.5f; _entryComplete = false; _destinationTile.ObstructedBy = TileBlockers.Bug; _transform.position = _destinationTile.Position + (Vector3.up * 12.0f); _transform.localScale = Vector3.one * _scale; _animator.enabled = true; _rigidbody.constraints = _startingConstraints; _rigidbody.velocity = new Vector3(0.0f, -1.0f, 0.0f); _soundEffect.volume = 0.0f; }