移除错误的玩家预制体

This commit is contained in:
2026-09-17 22:22:04 +08:00
parent 3439853782
commit ef69939fa1
5 changed files with 0 additions and 522 deletions
-1
View File
@@ -21,7 +21,6 @@ MonoBehaviour:
- {fileID: 201277550, guid: 5b712878ecece354ba4ffb026c0a221c, type: 3} - {fileID: 201277550, guid: 5b712878ecece354ba4ffb026c0a221c, type: 3}
- {fileID: 4512293259955182956, guid: b8017cef39731ba439c70fecc09488e3, type: 3} - {fileID: 4512293259955182956, guid: b8017cef39731ba439c70fecc09488e3, type: 3}
- {fileID: 201277550, guid: 26a567abbe21227428f5c3d309d1d73c, type: 3} - {fileID: 201277550, guid: 26a567abbe21227428f5c3d309d1d73c, type: 3}
- {fileID: 3597132959123631746, guid: 687b16b0a8065d74fa4380e93a8a3d81, type: 3}
- {fileID: 4512293259955182956, guid: 44611030e61220d42ab7c37ba3c0ea92, type: 3} - {fileID: 4512293259955182956, guid: 44611030e61220d42ab7c37ba3c0ea92, type: 3}
- {fileID: 8192566354860284824, guid: 6331b3542e64a564c81bc39cedf70c8d, type: 3} - {fileID: 8192566354860284824, guid: 6331b3542e64a564c81bc39cedf70c8d, type: 3}
- {fileID: 4512293259955182956, guid: f32d4c19de900e64cb73cedcb8ba6f70, type: 3} - {fileID: 4512293259955182956, guid: f32d4c19de900e64cb73cedcb8ba6f70, type: 3}
-293
View File
@@ -1,293 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &5354570318818660711
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1970733545076781942}
- component: {fileID: 2574156275777457598}
- component: {fileID: 1210119558697661830}
- component: {fileID: 3597132959123631746}
- component: {fileID: 4770153168491883514}
m_Layer: 0
m_Name: Player
m_TagString: Player
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1970733545076781942
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5354570318818660711}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 7234523343942154409}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!143 &2574156275777457598
CharacterController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5354570318818660711}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Height: 1.8
m_Radius: 0.4
m_SlopeLimit: 45
m_StepOffset: 0.35
m_SkinWidth: 0.08
m_MinMoveDistance: 0.001
m_Center: {x: 0, y: 0.9, z: 0}
--- !u!114 &1210119558697661830
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5354570318818660711}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b6780c1c0b9d27c46a0bd43f0d2291f6, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::PlayerController
actionsAsset: {fileID: -944628639613478452, guid: 052faaac586de48259a63d0c4782560b, type: 3}
moveAction: {fileID: 0}
jumpAction: {fileID: 0}
sprintAction: {fileID: 0}
walkSpeed: 5
sprintMultiplier: 1.8
acceleration: 14
rotationSpeed: 14
jumpHeight: 1.4
gravity: -22
groundedForce: -2
groundCheckRadius: 0.28
groundCheckOffset: -0.92
groundMask:
serializedVersion: 2
m_Bits: 4294967295
cameraPivot: {fileID: 0}
createCameraIfMissing: 1
controlCursor: 1
lookSensitivity: 0.12
pitchMin: -35
pitchMax: 70
cameraDistance: 5
cameraHeight: 1.2
cameraSideOffset: 0.6
--- !u!114 &3597132959123631746
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5354570318818660711}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 26b716c41e9b56b4baafaf13a523ba2e, type: 3}
m_Name:
m_EditorClassIdentifier: FishNet.Runtime::FishNet.Object.NetworkObject
_localLevelOfDetailCalculationType: 0
_useLevelOfDetail: 0
_useRootLevelOfDetail: 1
NetworkObserver: {fileID: 0}
_enablePrediction: 0
_predictionType: 0
_localReconcileCorrectionType: 2
_graphicalObject: {fileID: 0}
_detachGraphicalObject: 0
_enableStateForwarding: 1
_networkTransform: {fileID: 0}
_ownerInterpolation: 1
_ownerSmoothedProperties: 255
_adaptiveInterpolation: 3
_spectatorSmoothedProperties: 255
_spectatorInterpolation: 2
_enableTeleport: 0
_teleportThreshold: 1
<PrefabId>k__BackingField: 65535
<SpawnableCollectionId>k__BackingField: 0
<AssetPathHash>k__BackingField: 15157568118727023227
SceneId: 0
SerializedTransformProperties:
Position: {x: 0, y: 0, z: 0}
Rotation: {x: 0, y: 0, z: 0, w: 0}
Scale: {x: 0, y: 0, z: 0}
IsValid: 0
<IsNested>k__BackingField: 0
WasActiveDuringEdit: 0
WasActiveDuringEdit_Set1: 1
<ComponentIndex>k__BackingField: 0
<PredictedSpawn>k__BackingField: {fileID: 0}
<PredictedOwner>k__BackingField: {fileID: 0}
NetworkBehaviours: []
InitializedParentNetworkBehaviour: {fileID: 0}
InitializedNestedNetworkObjects: []
RuntimeParentNetworkBehaviour: {fileID: 0}
RuntimeChildNetworkBehaviours: []
_isNetworked: 1
_isSpawnable: 1
_isGlobal: 0
_initializeOrder: 0
_preventDespawnOnDisconnect: 0
_defaultDespawnType: 0
_initializedTimestamp: 0
--- !u!114 &4770153168491883514
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5354570318818660711}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a2836e36774ca1c4bbbee976e17b649c, type: 3}
m_Name:
m_EditorClassIdentifier: FishNet.Runtime::FishNet.Component.Transforming.NetworkTransform
_componentIndexCache: 255
_addedNetworkObject: {fileID: 3597132959123631746}
_networkObjectCache: {fileID: 0}
_componentConfiguration: 0
_synchronizeParent: 0
_packing:
Position: 1
Rotation: 1
Scale: 0
_useScaledTime: 1
_interpolation: 2
_extrapolation: 2
_enableTeleport: 0
_teleportThreshold: 1
_clientAuthoritative: 1
_sendToOwner: 1
_interval: 1
_synchronizePosition: 1
_positionSensitivity: 0.001
_positionSnapping:
X: 0
Y: 0
Z: 0
_synchronizeRotation: 1
_rotationSnapping:
X: 0
Y: 0
Z: 0
_synchronizeScale: 1
_scaleSensitivity: 0.001
_scaleSnapping:
X: 0
Y: 0
Z: 0
--- !u!1 &6149029535851407841
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7234523343942154409}
- component: {fileID: 5382409320781136276}
- component: {fileID: 4998907831547767837}
m_Layer: 0
m_Name: Body
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7234523343942154409
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6149029535851407841}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0.9, z: 0}
m_LocalScale: {x: 0.9, y: 0.9, z: 0.9}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1970733545076781942}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &5382409320781136276
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6149029535851407841}
m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &4998907831547767837
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6149029535851407841}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_SmallMeshCulling: 1
m_ForceMeshLod: -1
m_MeshLodSelectionBias: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_GlobalIlluminationMeshLod: 0
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_MaskInteraction: 0
m_AdditionalVertexStreams: {fileID: 0}
-7
View File
@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 687b16b0a8065d74fa4380e93a8a3d81
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
-219
View File
@@ -1,219 +0,0 @@
using UnityEngine;
using UnityEngine.InputSystem;
/// <summary>
/// Capsule player: camera-relative movement, jump, gravity and mouse look.
/// Input comes from the project asset Assets/InputSystem_Actions.inputactions
/// ("Player" map: Move / Jump / Sprint).
/// </summary>
[RequireComponent(typeof(CharacterController))]
public class PlayerController : MonoBehaviour
{
[Header("Input")]
[Tooltip("Optional: the project's InputSystem_Actions asset. Actions are resolved by name from it.")]
[SerializeField] private InputActionAsset actionsAsset;
[Tooltip("Optional explicit references. Take priority over actionsAsset when set.")]
[SerializeField] private InputActionReference moveAction;
[SerializeField] private InputActionReference jumpAction;
[SerializeField] private InputActionReference sprintAction;
private InputAction _move;
private InputAction _jump;
private InputAction _sprint;
[Header("Movement")]
[SerializeField] private float walkSpeed = 5f;
[SerializeField] private float sprintMultiplier = 1.8f;
[SerializeField] private float acceleration = 14f;
[SerializeField] private float rotationSpeed = 14f;
[SerializeField] private float jumpHeight = 1.4f;
[Header("Gravity")]
[SerializeField] private float gravity = -22f;
[SerializeField] private float groundedForce = -2f;
[Tooltip("Extra ground probe at the feet, in addition to CharacterController.isGrounded.")]
[SerializeField] private float groundCheckRadius = 0.12f;
[Tooltip("Probe height relative to the transform origin. The capsule's feet are at y = 0.")]
[SerializeField] private float groundCheckOffset = 0.12f;
[SerializeField] private LayerMask groundMask = ~0;
[Header("Camera")]
[SerializeField] private Transform cameraPivot;
[Tooltip("Create a third-person camera at runtime when the scene has no Main Camera.")]
[SerializeField] private bool createCameraIfMissing = true;
[SerializeField] private bool controlCursor = true;
[SerializeField] private float lookSensitivity = 0.12f;
[SerializeField] private float pitchMin = -35f;
[SerializeField] private float pitchMax = 70f;
[SerializeField] private float cameraDistance = 5f;
[SerializeField] private float cameraHeight = 1.2f;
[SerializeField] private float cameraSideOffset = 0.6f;
private CharacterController _controller;
private Vector3 _planarVelocity;
private float _verticalVelocity;
private bool _grounded;
private float _yaw;
private float _pitch = 15f;
private Camera _camera;
public bool IsGrounded { get { return _grounded; } }
public float CurrentSpeed { get { return _planarVelocity.magnitude; } }
private void Awake()
{
_controller = GetComponent<CharacterController>();
_yaw = transform.eulerAngles.y;
ResolveActions();
EnableActions(true);
}
/// <summary>
/// Prefers explicit InputActionReference fields, otherwise resolves
/// "Player/Move", "Player/Jump" and "Player/Sprint" from the actions asset.
/// </summary>
private void ResolveActions()
{
_move = moveAction != null ? moveAction.action : null;
_jump = jumpAction != null ? jumpAction.action : null;
_sprint = sprintAction != null ? sprintAction.action : null;
if (actionsAsset == null) return;
if (_move == null) _move = actionsAsset.FindAction("Player/Move", false);
if (_jump == null) _jump = actionsAsset.FindAction("Player/Jump", false);
if (_sprint == null) _sprint = actionsAsset.FindAction("Player/Sprint", false);
}
private void OnEnable()
{
EnableActions(true);
if (controlCursor)
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
}
private void OnDisable()
{
if (controlCursor)
{
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
}
private void EnableActions(bool enable)
{
SetEnabled(_move, enable);
SetEnabled(_jump, enable);
SetEnabled(_sprint, enable);
}
private static void SetEnabled(InputAction action, bool enable)
{
if (action == null) return;
if (enable) action.Enable();
else action.Disable();
}
private void Update()
{
ReadLook();
ReadMove();
ApplyGravityAndJump();
Move();
UpdateCamera();
}
private void ReadLook()
{
if (Mouse.current == null) return;
Vector2 delta = Mouse.current.delta.ReadValue() * lookSensitivity;
_yaw += delta.x;
_pitch = Mathf.Clamp(_pitch - delta.y, pitchMin, pitchMax);
}
private void ReadMove()
{
Vector2 input = _move != null ? _move.ReadValue<Vector2>() : Vector2.zero;
Quaternion yawRotation = Quaternion.Euler(0f, _yaw, 0f);
Vector3 desired = yawRotation * new Vector3(input.x, 0f, input.y);
if (desired.sqrMagnitude > 1f) desired.Normalize();
float speed = walkSpeed;
if (_sprint != null && _sprint.IsPressed())
speed *= sprintMultiplier;
_planarVelocity = Vector3.MoveTowards(_planarVelocity, desired * speed, acceleration * Time.deltaTime);
}
private void ApplyGravityAndJump()
{
// CharacterController.isGrounded is the authoritative check (its capsule
// matches the visual): the extra sphere probe only helps on slopes/steps.
Vector3 origin = transform.position + Vector3.up * groundCheckOffset;
bool probeHit = Physics.CheckSphere(origin, groundCheckRadius, groundMask, QueryTriggerInteraction.Ignore);
_grounded = _controller.isGrounded || probeHit;
if (_grounded && _verticalVelocity < 0f) _verticalVelocity = groundedForce;
bool wantsJump = _jump != null && _jump.WasPressedThisFrame();
if (wantsJump && _grounded)
_verticalVelocity = Mathf.Sqrt(jumpHeight * -2f * gravity);
_verticalVelocity += gravity * Time.deltaTime;
}
private void Move()
{
Vector3 motion = _planarVelocity + Vector3.up * _verticalVelocity;
_controller.Move(motion * Time.deltaTime);
if (_planarVelocity.sqrMagnitude > 0.05f)
{
Quaternion target = Quaternion.LookRotation(_planarVelocity.normalized, Vector3.up);
transform.rotation = Quaternion.Slerp(transform.rotation, target, rotationSpeed * Time.deltaTime);
}
}
private void UpdateCamera()
{
if (_camera == null)
{
_camera = Camera.main;
if (_camera == null && createCameraIfMissing)
_camera = CreateFallbackCamera();
if (_camera == null) return;
}
Transform pivot = cameraPivot != null ? cameraPivot : transform;
Vector3 pivotPoint = pivot.position + Vector3.up * cameraHeight + pivot.right * cameraSideOffset;
Quaternion rotation = Quaternion.Euler(_pitch, _yaw, 0f);
Vector3 position = pivotPoint + rotation * new Vector3(0f, 0f, -cameraDistance);
_camera.transform.SetPositionAndRotation(position, rotation);
}
/// <summary>
/// Builds a third-person camera at runtime so the prefab is playable even in
/// a scene that has no camera. Only used when not overridden by an existing Main Camera.
/// </summary>
private static Camera CreateFallbackCamera()
{
GameObject cameraObject = new GameObject("PlayerCamera");
cameraObject.tag = "MainCamera";
Camera camera = cameraObject.AddComponent<Camera>();
camera.fieldOfView = 60f;
camera.nearClipPlane = 0.1f;
camera.farClipPlane = 1000f;
cameraObject.AddComponent<AudioListener>();
return camera;
}
private void OnDrawGizmosSelected()
{
Gizmos.color = Color.yellow;
Gizmos.DrawWireSphere(transform.position + Vector3.up * groundCheckOffset, groundCheckRadius);
}}
@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: b6780c1c0b9d27c46a0bd43f0d2291f6