/**************************************************************************************************/ //calculates velocity to move horizontaly //*call after calculating move type public void HorizontalMovment() { if (characterMovement.sides.bot && !(jumping || falling)) //on the ground and not jumping or falling { if (moveType > 0 && !stopToAttack) //move type over 0 and not sotping to attack { float disToPlayer = Mathf.Abs(transform.position.x - bossPathing.GetPoint().x); //distance to player if (bossPathing.chasing && disToPlayer > 10) //boss is chasing player and player further than 10 away { velocity.x = sprintSpeed; //set x of velocity to sprint speed sprinting = true; //is sprinting } else { velocity.x = walkSpeed; //set x of velocity to walking speed walking = true; //is waliking } } else { velocity.x = 0; //else set x of velocity to 0 } numberOfJumps = maxNumberOfJumps; //reset number of jumps } if (moveType == 0) //if move type equals 0 { walking = sprinting = false; //sprinting and walking equal false } velocity.x *= direction.x; //set x of veloctiy in direction }
private void FixedUpdate() { if (!dead)//Spencer { if (GetCharacterMovement().sides.bot) { SetDirection(bossPathing.GetPoint()); } ResetState(); CalculateMoveType(bossPathing.myBounds.xhalf); HorizontalMovment(); VerticalMovement(); Vector3 temp = GetVelocity(); //transform.Translate(temp); transform.Translate(new Vector3(Mathf.Abs(temp.x) * -1, temp.y)); } else { //Spencer, need to get him to stop running bearController.AddFlopPriority(); } }