Как исправить эту ошибку, если она не имеет определения? Любая помощь будет очень признательна!
using System; using UnityEngine; using UnityEngine.Events; using UnityStandardAssets.CrossPlatformInput; using UnityStandardAssets.Characters.FirstPerson; namespace UnityStandardAssets.Characters.FirstPerson { [RequireComponent(typeof (Rigidbody))] [RequireComponent(typeof (CapsuleCollider))] [RequireComponent(typeof (PlayerInputHandler))] public class RigidbodyFirstPersonController : MonoBehaviour { [Serializable] public class MovementSettings { public float ForwardSpeed = 8.0f; // Speed when walking forward public float BackwardSpeed = 4.0f; // Speed when walking backwards public float StrafeSpeed = 4.0f; // Speed when walking sideways public float RunMultiplier = 2.0f; // Speed when sprinting public KeyCode RunKey = KeyCode.LeftShift; public float jumpForce = 30f; public AnimationCurve SlopeCurveModifier = new AnimationCurve(new Keyframe(-90.0f, 1.0f), new Keyframe(0.0f, 1.0f), new Keyframe(90.0f, 0.0f)); [HideInInspector] public float CurrentTargetSpeed = 8f; private bool m_Running; public void UpdateDesiredTargetSpeed(Vector2 input) { if (input == Vector2.zero) return; if (input.x > 0 || input.x < 0) { //strafe CurrentTargetSpeed = StrafeSpeed; } if (input.y < 0) { //backwards CurrentTargetSpeed = BackwardSpeed; } if (input.y > 0) { //forwards //handled last as if strafing and moving forward at the same time forwards speed should take precedence CurrentTargetSpeed = ForwardSpeed; } if (Input.GetKey(RunKey)) { CurrentTargetSpeed *= RunMultiplier; m_Running = true; } else { m_Running = false; } } public bool Running { get { return m_Running; } } } [Serializable] public class AdvancedSettings { public float groundCheckDistance = 0.01f; // distance for checking if the controller is grounded ( 0.01f seems to work best for this ) public float stickToGroundHelperDistance = 0.5f; // stops the character public float slowDownRate = 20f; // rate at which the controller comes to a stop when there is no input public bool airControl; // can the user control the direction that is being moved in the air [Tooltip("set it to 0.1 or more if you get stuck in wall")] public float shellOffset; //reduce the radius by that ratio to avoid getting stuck in wall (a value of 0.1f is nice) } [Header("References")] public AudioSource audioSource; public Camera cam; public MovementSettings movementSettings = new MovementSettings(); public MouseLook mouseLook = new MouseLook(); public AdvancedSettings advancedSettings = new AdvancedSettings(); [Header("Stance")] [Tooltip("Ratio (0-1) of the character height where the camera will be at")] public float cameraHeightRatio = 0.9f; [Tooltip("Height of character when standing")] public float capsuleHeightStanding = 1.8f; [Tooltip("Height of character when crouching")] public float capsuleHeightCrouching = 0.9f; [Tooltip("Speed of crouching transitions")] public float crouchingSharpness = 10f; [Header("General")] [Tooltip("Force applied downward when in the air")] public float gravityDownForce = 20f; [Tooltip("Physic layers checked to consider the player grounded")] public LayerMask groundCheckLayers = -1; [Tooltip("distance from the bottom of the character controller capsule to test for grounded")] public float groundCheckDistance = 0.05f; [Header("Movement")] [Tooltip("Max movement speed when grounded (when not sprinting)")] public float maxSpeedOnGround = 10f; [Tooltip("Sharpness for the movement when grounded, a low value will make the player accelerate and decelerate slowly, a high value will do the opposite")] public float movementSharpnessOnGround = 15; [Tooltip("Max movement speed when crouching")] [Range(0,1)] public float maxSpeedCrouchedRatio = 0.5f; [Tooltip("Max movement speed when not grounded")] public float maxSpeedInAir = 10f; [Tooltip("Acceleration speed when in the air")] public float accelerationSpeedInAir = 25f; [Tooltip("Multiplicator for the sprint speed (based on grounded speed)")] public float sprintSpeedModifier = 2f; [Tooltip("Height at which the player dies instantly when falling off the map")] public float killHeight = -50f; [Header("Audio")] [Tooltip("Amount of footstep sounds played when moving one meter")] public float footstepSFXFrequency = 1f; [Tooltip("Amount of footstep sounds played when moving one meter while sprinting")] public float footstepSFXFrequencyWhileSprinting = 1f; [Tooltip("Sound played for footsteps")] public AudioClip footstepSFX; [Tooltip("Sound played when jumping")] public AudioClip jumpSFX; [Tooltip("Sound played when landing")] public AudioClip landSFX; [Tooltip("Sound played when taking damage froma fall")] public AudioClip fallDamageSFX; [Header("Fall Damage")] [Tooltip("Whether the player will recieve damage when hitting the ground at high speed")] public bool recievesFallDamage; [Tooltip("Minimun fall speed for recieving fall damage")] public float minSpeedForFallDamage = 10f; [Tooltip("Fall speed for recieving th emaximum amount of fall damage")] public float maxSpeedForFallDamage = 30f; [Tooltip("Damage recieved when falling at the mimimum speed")] public float fallDamageAtMinSpeed = 10f; [Tooltip("Damage recieved when falling at the maximum speed")] public float fallDamageAtMaxSpeed = 50f; Health m_Health; PlayerInputHandler m_InputHandler; Actor m_Actor; PlayerWeaponsManager m_WeaponsManager; public Rigidbody m_RigidBody; public CapsuleCollider m_Capsule; private float m_YRotation; private Vector3 m_GroundContactNormal; Vector3 m_GroundNormal; Vector3 m_LatestImpactSpeed; private bool m_Jump, m_PreviouslyGrounded, m_Jumping, m_IsGrounded; public bool hasJumpedThisFrame { get; private set; } float m_LastTimeJumped = 0f; float m_footstepDistanceCounter; float m_TargetCharacterHeight; public Vector3 characterVelocity { get; set; } const float k_GroundCheckDistanceInAir = 0.07f; public bool isCrouching { get; private set; } public UnityAction<bool> onStanceChanged; // Gets the center point of the bottom hemisphere of the character controller capsule Vector3 GetCapsuleBottomHemisphere() { return transform.position + (transform.up * m_Capsule.radius); } // Gets the center point of the top hemisphere of the character controller capsule Vector3 GetCapsuleTopHemisphere(float atHeight) { return transform.position + (transform.up * (atHeight - m_Capsule.radius)); } public Vector3 Velocity { get { return m_RigidBody.velocity; } } public bool Grounded { get { return m_IsGrounded; } } public bool Jumping { get { return m_Jumping; } } public bool Running { get { return movementSettings.Running; return false; } } public void Start() { m_RigidBody = GetComponent<Rigidbody>(); m_Capsule = GetComponent<CapsuleCollider>(); mouseLook.Init (transform, cam.transform); SetCrouchingState(false, true); UpdateCharacterHeight(true); m_InputHandler = GetComponent<PlayerInputHandler>(); DebugUtility.HandleErrorIfNullGetComponent<PlayerInputHandler, RigidbodyFirstPersonController>(m_InputHandler, this, gameObject); m_WeaponsManager = GetComponent<PlayerWeaponsManager>(); DebugUtility.HandleErrorIfNullGetComponent<PlayerWeaponsManager, RigidbodyFirstPersonController>(m_WeaponsManager, this, gameObject); m_Actor = GetComponent<Actor>(); DebugUtility.HandleErrorIfNullGetComponent<Actor, RigidbodyFirstPersonController>(m_Actor, this, gameObject); } public void HandleCharacterMovement() { // Gets a reoriented direction that is tangent to a given slope Vector3 GetDirectionReorientedOnSlope(Vector3 direction, Vector3 slopeNormal) { Vector3 directionRight = Vector3.Cross(direction, transform.up); return Vector3.Cross(slopeNormal, directionRight).normalized; } // character movement handling bool isSprinting = m_InputHandler.GetSprintInputHeld(); { if (isSprinting) { isSprinting = SetCrouchingState(false, false); } float speedModifier = isSprinting ? sprintSpeedModifier : 1f; // converts move input to a worldspace vector based on our character's transform orientation Vector3 worldspaceMoveInput = transform.TransformVector(m_InputHandler.GetMoveInput()); // handle grounded movement if (m_IsGrounded) { // calculate the desired velocity from inputs, max speed, and current slope Vector3 targetVelocity = worldspaceMoveInput * maxSpeedOnGround * speedModifier; // reduce speed if crouching by crouch speed ratio if (isCrouching) targetVelocity *= maxSpeedCrouchedRatio; targetVelocity = GetDirectionReorientedOnSlope(targetVelocity.normalized, m_GroundNormal) * targetVelocity.magnitude; // smoothly interpolate between our current velocity and the target velocity based on acceleration speed characterVelocity = Vector3.Lerp(characterVelocity, targetVelocity, movementSharpnessOnGround * Time.deltaTime); // jumping if (m_IsGrounded && m_InputHandler.GetJumpInputDown()) { // force the crouch state to false if (SetCrouchingState(false, false)) { // start by canceling out the vertical component of our velocity characterVelocity = new Vector3(characterVelocity.x, 0f, characterVelocity.z); // then, add the jumpSpeed value upwards characterVelocity += Vector3.up * movementSettings.jumpForce; // play sound audioSource.PlayOneShot(jumpSFX); // remember last time we jumped because we need to prevent snapping to ground for a short time m_LastTimeJumped = Time.time; hasJumpedThisFrame = true; // Force grounding to false m_IsGrounded = false; m_GroundNormal = Vector3.up; } } // footsteps sound float chosenFootstepSFXFrequency = (isSprinting ? footstepSFXFrequencyWhileSprinting : footstepSFXFrequency); if (m_footstepDistanceCounter >= 1f / chosenFootstepSFXFrequency) { m_footstepDistanceCounter = 0f; audioSource.PlayOneShot(footstepSFX); } // keep track of distance traveled for footsteps sound m_footstepDistanceCounter += characterVelocity.magnitude * Time.deltaTime; } // handle air movement else { // add air acceleration characterVelocity += worldspaceMoveInput * accelerationSpeedInAir * Time.deltaTime; // limit air speed to a maximum, but only horizontally float verticalVelocity = characterVelocity.y; Vector3 horizontalVelocity = Vector3.ProjectOnPlane(characterVelocity, Vector3.up); horizontalVelocity = Vector3.ClampMagnitude(horizontalVelocity, maxSpeedInAir * speedModifier); characterVelocity = horizontalVelocity + (Vector3.up * verticalVelocity); // apply the gravity to the velocity characterVelocity += Vector3.down * gravityDownForce * Time.deltaTime; } } // apply the final calculated velocity value as a character movement Vector3 capsuleBottomBeforeMove = GetCapsuleBottomHemisphere(); Vector3 capsuleTopBeforeMove = GetCapsuleTopHemisphere(m_Capsule.height); m_Capsule.Move(characterVelocity * Time.deltaTime); // detect obstructions to adjust velocity accordingly m_LatestImpactSpeed = Vector3.zero; if (Physics.CapsuleCast(capsuleBottomBeforeMove, capsuleTopBeforeMove, m_Capsule.radius, characterVelocity.normalized, out RaycastHit hit, characterVelocity.magnitude * Time.deltaTime, -1, QueryTriggerInteraction.Ignore)) { // We remember the last impact speed because the fall damage logic might need it m_LatestImpactSpeed = characterVelocity; characterVelocity = Vector3.ProjectOnPlane(characterVelocity, hit.normal); } } public void Update() { RotateView(); hasJumpedThisFrame = false; bool wasGrounded = m_IsGrounded; GroundCheck(); // landing if (m_IsGrounded && !wasGrounded) { // Fall damage float fallSpeed = -Mathf.Min(characterVelocity.y, m_LatestImpactSpeed.y); float fallSpeedRatio = (fallSpeed - minSpeedForFallDamage) / (maxSpeedForFallDamage - minSpeedForFallDamage); if (recievesFallDamage && fallSpeedRatio > 0f) { float dmgFromFall = Mathf.Lerp(fallDamageAtMinSpeed, fallDamageAtMaxSpeed, fallSpeedRatio); m_Health.TakeDamage(dmgFromFall, null); // fall damage SFX audioSource.PlayOneShot(fallDamageSFX); } else { // land SFX audioSource.PlayOneShot(landSFX); } } if (CrossPlatformInputManager.GetButtonDown("Jump") && !m_Jump) { m_Jump = true; } if (CrossPlatformInputManager.GetButtonDown("Crouch")) { SetCrouchingState(!isCrouching, false); } UpdateCharacterHeight(false); HandleCharacterMovement(); } void UpdateCharacterHeight(bool force) { // Update height instantly if (force) { m_Capsule.height = m_TargetCharacterHeight; m_Capsule.center = Vector3.up * m_Capsule.height * 0.5f; cam.transform.localPosition = Vector3.up * m_TargetCharacterHeight * cameraHeightRatio; m_Actor.aimPoint.transform.localPosition = m_Capsule.center; } // Update smooth height else if (m_Capsule.height != m_TargetCharacterHeight) { // resize the capsule and adjust camera position m_Capsule.height = Mathf.Lerp(m_Capsule.height, m_TargetCharacterHeight, crouchingSharpness * Time.deltaTime); m_Capsule.center = Vector3.up * m_Capsule.height * 0.5f; cam.transform.localPosition = Vector3.Lerp(cam.transform.localPosition, Vector3.up * m_TargetCharacterHeight * cameraHeightRatio, crouchingSharpness * Time.deltaTime); m_Actor.aimPoint.transform.localPosition = m_Capsule.center; } } // returns false if there was an obstruction bool SetCrouchingState(bool crouched, bool ignoreObstructions) { // set appropriate heights if (crouched) { m_TargetCharacterHeight = capsuleHeightCrouching; } else { // Detect obstructions if (!ignoreObstructions) { Collider[] standingOverlaps = Physics.OverlapCapsule( GetCapsuleBottomHemisphere(), GetCapsuleTopHemisphere(capsuleHeightStanding), m_Capsule.radius, -1, QueryTriggerInteraction.Ignore); foreach (Collider c in standingOverlaps) { if (c != m_Capsule) { return false; } } } m_TargetCharacterHeight = capsuleHeightStanding; } if (onStanceChanged != null) { onStanceChanged.Invoke(crouched); } isCrouching = crouched; return true; } public void FixedUpdate() { GroundCheck(); Vector2 input = GetInput(); if ((Mathf.Abs(input.x) > float.Epsilon || Mathf.Abs(input.y) > float.Epsilon) && (advancedSettings.airControl || m_IsGrounded)) { // always move along the camera forward as it is the direction that it being aimed at Vector3 desiredMove = cam.transform.forward*input.y + cam.transform.right*input.x; desiredMove = Vector3.ProjectOnPlane(desiredMove, m_GroundContactNormal).normalized; desiredMove.x = desiredMove.x*movementSettings.CurrentTargetSpeed; desiredMove.z = desiredMove.z*movementSettings.CurrentTargetSpeed; desiredMove.y = desiredMove.y*movementSettings.CurrentTargetSpeed; if (m_RigidBody.velocity.sqrMagnitude < (movementSettings.CurrentTargetSpeed*movementSettings.CurrentTargetSpeed)) { m_RigidBody.AddForce(desiredMove*SlopeMultiplier(), ForceMode.Impulse); } } if (m_IsGrounded) { m_RigidBody.drag = 5f; if (m_Jump) { m_RigidBody.drag = 0f; m_RigidBody.velocity = new Vector3(m_RigidBody.velocity.x, 0f, m_RigidBody.velocity.z); m_RigidBody.AddForce(new Vector3(0f, movementSettings.jumpForce, 0f), ForceMode.Impulse); m_Jumping = true; } if (!m_Jumping && Mathf.Abs(input.x) < float.Epsilon && Mathf.Abs(input.y) < float.Epsilon && m_RigidBody.velocity.magnitude < 1f) { m_RigidBody.Sleep(); } } else { m_RigidBody.drag = 0f; if (m_PreviouslyGrounded && !m_Jumping) { StickToGroundHelper(); } } m_Jump = false; } private float SlopeMultiplier() { float angle = Vector3.Angle(m_GroundContactNormal, Vector3.up); return movementSettings.SlopeCurveModifier.Evaluate(angle); } private void StickToGroundHelper() { RaycastHit hitInfo; if (Physics.SphereCast(transform.position, m_Capsule.radius * (1.0f - advancedSettings.shellOffset), Vector3.down, out hitInfo, ((m_Capsule.height/2f) - m_Capsule.radius) + advancedSettings.stickToGroundHelperDistance, Physics.AllLayers, QueryTriggerInteraction.Ignore)) { if (Mathf.Abs(Vector3.Angle(hitInfo.normal, Vector3.up)) < 85f) { m_RigidBody.velocity = Vector3.ProjectOnPlane(m_RigidBody.velocity, hitInfo.normal); } } } private Vector2 GetInput() { Vector2 input = new Vector2 { x = CrossPlatformInputManager.GetAxis("Horizontal"), y = CrossPlatformInputManager.GetAxis("Vertical") }; movementSettings.UpdateDesiredTargetSpeed(input); return input; } private void RotateView() { //avoids the mouse looking if the game is effectively paused if (Mathf.Abs(Time.timeScale) < float.Epsilon) return; // get the rotation before it's changed float oldYRotation = transform.eulerAngles.y; mouseLook.LookRotation (transform, cam.transform); if (m_IsGrounded || advancedSettings.airControl) { // Rotate the rigidbody velocity to match the new direction that the character is looking Quaternion velRotation = Quaternion.AngleAxis(transform.eulerAngles.y - oldYRotation, Vector3.up); m_RigidBody.velocity = velRotation*m_RigidBody.velocity; } } /// sphere cast down just beyond the bottom of the capsule to see if the capsule is colliding round the bottom public void GroundCheck() { float chosenGroundCheckDistance = m_IsGrounded ? (m_Capsule.radius + groundCheckDistance) : k_GroundCheckDistanceInAir; m_PreviouslyGrounded = m_IsGrounded; RaycastHit hitInfo; if (Physics.SphereCast(transform.position, m_Capsule.radius * (1.0f - advancedSettings.shellOffset), Vector3.down, out hitInfo, ((m_Capsule.height/2f) - m_Capsule.radius) + advancedSettings.groundCheckDistance, Physics.AllLayers, QueryTriggerInteraction.Ignore)) { m_IsGrounded = true; m_GroundContactNormal = hitInfo.normal; } else { m_IsGrounded = false; m_GroundContactNormal = Vector3.up; } if (!m_PreviouslyGrounded && m_IsGrounded && m_Jumping) { m_Jumping = false; } if (Physics.CapsuleCast(GetCapsuleBottomHemisphere(), GetCapsuleTopHemisphere(m_Capsule.height), m_Capsule.radius, Vector3.down, out RaycastHit hit, chosenGroundCheckDistance, groundCheckLayers, QueryTriggerInteraction.Ignore)) { // storing the upward direction for the surface found m_GroundNormal = hit.normal; } // handle snapping to the ground if (hit.distance > m_Capsule.radius) { m_Capsule.Move(Vector3.down * hit.distance); } } } }
Что я уже пробовал:
Assets\Scripts\RigidbodyFirstPersonController.cs(345,23): error CS1061: 'CapsuleCollider' does not contain a definition for 'Move' and no accessible extension method 'Move' accepting a first argument of type 'CapsuleCollider' could be found (are you missing a using directive or an assembly reference?)
BillWoodruff
Что документы Unity описывают как допустимые методы для этого класса ?