// Start is called before the first frame update private void Start() { playerMovement = GetComponent <PlayerMovement>(); if (Camera.main != null) { mainCamera = Camera.main; _cameraEffect = mainCamera.GetComponent <CameraEffect>(); } isFacingRight = true; onFacingChangeCallback?.Invoke(true); canControl = true; }
private void Update() { if (attack) { animator.SetFloat(Vertical, 0f); animator.SetFloat(Horizontal, 0f); return; } if (Mathf.Abs(input.Vertical) > 0) { animator.SetFloat(Vertical, input.Vertical); animator.SetFloat(Horizontal, 0f); facing = input.Vertical < 0 ? 1 : 2; OnFacingChange?.Invoke(facing); } else if (Mathf.Abs(input.Horizontal) > 0) { animator.SetFloat(Horizontal, input.Horizontal); animator.SetFloat(Vertical, 0f); facing = input.Horizontal < 0 ? 3 : 4; OnFacingChange?.Invoke(facing); } else { animator.SetFloat(Vertical, 0f); animator.SetFloat(Horizontal, 0f); } animator.SetInteger(Facing, facing); }