protected Vector2 ProcessMovementInput(Vector2 _moveInput, LivingEntityStates states) { moveInput = _moveInput; //Calculate velocity.x float targetVX = moveSpeed * moveInput.x; velocity.x = Mathf.SmoothDamp(velocity.x, targetVX, ref velocityXSmooth, states.grounded ? accTimeGround : accTimeAir); velocity = ApplyPhysics(velocity); //Calculate velocity.y if (moveInput.y > 0)//Jump { if (controller.collisions.slidingDownMaxSlope) { if (moveInput.x != -Mathf.Sign(controller.collisions.slopeNormal.x))//not jumping againt max slope { velocity.y = jumpVelocity * controller.collisions.slopeNormal.y; velocity.x = jumpVelocity * controller.collisions.slopeNormal.x; } } else { velocity.y = moveInput.y * jumpVelocity; } } return(velocity * Time.deltaTime); }
public void Copy(LivingEntityStates states) { canMove = states.canMove; canAttack = states.canAttack; canPerformAction = states.canPerformAction; useGravity = states.useGravity; checkCollisions = states.checkCollisions; isRolling = states.isRolling; isAttacking = states.isAttacking; isClimbing = states.isClimbing; }
protected virtual void Start() { states = new LivingEntityStates(); states.facingRight = transform.root.rotation.eulerAngles.y == 90; health = startingHealth; }