/// <summary> /// Gets the movement from the Input Script or AI /// </summary> /// <param name="move"></param> /// <param name="active">Active = true means that is taking the Camera Input</param> public virtual void Move(Vector3 move, bool active = true) { if (active) { // convert the world relative moveInput vector into a local-relative // turn amount and forward amount required to head in the desired // direction. if (move.magnitude > 1f) { move.Normalize(); } move = transform.InverseTransformDirection(move); turnAmount = Mathf.Atan2(move.x, move.z); forwardAmount = move.z; movementAxis = new Vector3(turnAmount, movementAxis.y, Mathf.Abs(forwardAmount)); if (UpDownAxis && !jump && !down) //Up & Down movement while flying or swiming; { if (fly || underWater) { float a = move.y; if (a > 0) { a = a * 1.8f; } movementAxis.y = Mathf.Lerp(movementAxis.y, a, Time.deltaTime * 5f); } } if (!stand) { DragoTransform.Rotate(Vector3.up, movementAxis.x * Time.deltaTime * 40f); } } else { movementAxis = new Vector3(move.x, movementAxis.y, move.z); //Do not convert to Direction Input Mode (Camera or AI) } }
//--Add more Rotations to the current Turn animations ------------------------------------------- public virtual void TurnAmount() { float Turn; if (fly) { Turn = flyTurn; } else if (swim) { Turn = swimTurn; } else { Turn = TurnSpeed; if (!anim.GetCurrentAnimatorStateInfo(0).IsTag("Locomotion")) { Turn = 0; } } if (movementAxis.z >= 0) { DragoTransform.Rotate(DragoTransform.up, Turn * 3 * movementAxis.x * Time.deltaTime); } else { DragoTransform.Rotate(DragoTransform.up, Turn * 3 * -movementAxis.x * Time.deltaTime); } //More Rotation when jumping and falling... in air rotation------------------ if (isJumping() || fall && !fly && !swim && !stun) { if (movementAxis.z >= 0) { DragoTransform.Rotate(DragoTransform.up, 100 * movementAxis.x * Time.deltaTime); } else { DragoTransform.Rotate(DragoTransform.up, 100 * -movementAxis.x * Time.deltaTime); } } }