public override void PossessedUpdate() { float horizInput = Input.GetAxis("Horizontal"); float vertInput = 0; bool onGround = 0 < groundCollider.GetContacts(singleColliderArr); if (Input.GetButtonDown("Jump") && onGround) { vertInput = 1; animator.SetTrigger(animKeyJump); } Vector3 currScale = transform.localScale; if (horizInput < -0.1f) { currScale.x = -1; } else if (horizInput > 0.1f) { currScale.x = 1; } transform.localScale = currScale; animator.SetFloat(animKeyInputStrength, Mathf.Abs(horizInput)); movement.Move(horizInput, vertInput); }
void FixedUpdate() { if (IsPossessed) { return; } Vector2 moveDirection = movingLeft ? Vector2.left : Vector2.right; int layer = gameObject.layer; gameObject.layer = noRaycastLayer; Debug.DrawRay(transform.position, moveDirection * reverseRaycastLength, Color.red); if (Physics2D.Raycast(transform.position, moveDirection, reverseRaycastLength)) { movingLeft = !movingLeft; } gameObject.layer = layer; movement.Move(movingLeft ? -unpossessedSpeedMult : unpossessedSpeedMult, 0); }