private void OnTargetPosition() { timer += Time.deltaTime; if (timer >= timeOnTargetPos) { state = MovingObjectState.MovingTowardsStartPosition; timer = 0; } }
private void MovingTowardsTarget() { transform.position = Vector3.MoveTowards(transform.position, targetPosition, speedToTarget * Time.deltaTime); if (transform.position == targetPosition) { AudioManager.Instance.PlayAudioClip(soundOnImpact); state = MovingObjectState.OnTargetPosition; } }
private void Start() { targetPosition = target.position; startPosition = transform.position; timer = 0; state = MovingObjectState.OnStartPosition; canStartMoving = false; Invoke("EnableMovement", delay); }
private void MovingTowardsStartPosition() { transform.position = Vector3.MoveTowards(transform.position, startPosition, speedToInitialPos * Time.deltaTime); if (transform.position == startPosition) { if (!playSoundOnlyAtTargetPos) { AudioManager.Instance.PlayAudioClip(soundOnImpact); } state = MovingObjectState.OnStartPosition; } }