fix: PlayerMovement now works fine
update: Player no longer has Rigidbody add: added UserSettings to .gitignore .
This commit is contained in:
@@ -5,6 +5,8 @@
|
|||||||
[Bb]uilds/
|
[Bb]uilds/
|
||||||
[Ll]ogs/
|
[Ll]ogs/
|
||||||
|
|
||||||
|
[Uu]ser[Ss]ettings/
|
||||||
|
|
||||||
# Uncomment this line if you wish to ignore the asset store tools plugin
|
# Uncomment this line if you wish to ignore the asset store tools plugin
|
||||||
# [Aa]ssets/AssetStoreTools*
|
# [Aa]ssets/AssetStoreTools*
|
||||||
|
|
||||||
|
|||||||
@@ -496,7 +496,6 @@ GameObject:
|
|||||||
- component: {fileID: 2060574367}
|
- component: {fileID: 2060574367}
|
||||||
- component: {fileID: 2060574366}
|
- component: {fileID: 2060574366}
|
||||||
- component: {fileID: 2060574365}
|
- component: {fileID: 2060574365}
|
||||||
- component: {fileID: 2060574364}
|
|
||||||
- component: {fileID: 2060574363}
|
- component: {fileID: 2060574363}
|
||||||
- component: {fileID: 2060574362}
|
- component: {fileID: 2060574362}
|
||||||
- component: {fileID: 2060574368}
|
- component: {fileID: 2060574368}
|
||||||
@@ -523,7 +522,7 @@ MonoBehaviour:
|
|||||||
sprintSpeedMultiplier: 2
|
sprintSpeedMultiplier: 2
|
||||||
crouchSpeedMultiplier: 0.5
|
crouchSpeedMultiplier: 0.5
|
||||||
crouchHeightMultiplier: 0.5
|
crouchHeightMultiplier: 0.5
|
||||||
jumpForce: 1
|
jumpForce: 5
|
||||||
gravityMultiplier: 1
|
gravityMultiplier: 1
|
||||||
isCrouching: 0
|
isCrouching: 0
|
||||||
--- !u!143 &2060574363
|
--- !u!143 &2060574363
|
||||||
@@ -551,33 +550,6 @@ CharacterController:
|
|||||||
m_SkinWidth: 0.08
|
m_SkinWidth: 0.08
|
||||||
m_MinMoveDistance: 0.001
|
m_MinMoveDistance: 0.001
|
||||||
m_Center: {x: 0, y: 0, z: 0}
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
--- !u!54 &2060574364
|
|
||||||
Rigidbody:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 2060574361}
|
|
||||||
serializedVersion: 4
|
|
||||||
m_Mass: 1
|
|
||||||
m_Drag: 0
|
|
||||||
m_AngularDrag: 0.05
|
|
||||||
m_CenterOfMass: {x: 0, y: 0, z: 0}
|
|
||||||
m_InertiaTensor: {x: 1, y: 1, z: 1}
|
|
||||||
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
|
|
||||||
m_IncludeLayers:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Bits: 0
|
|
||||||
m_ExcludeLayers:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Bits: 0
|
|
||||||
m_ImplicitCom: 1
|
|
||||||
m_ImplicitTensor: 1
|
|
||||||
m_UseGravity: 1
|
|
||||||
m_IsKinematic: 0
|
|
||||||
m_Interpolate: 0
|
|
||||||
m_Constraints: 0
|
|
||||||
m_CollisionDetection: 0
|
|
||||||
--- !u!23 &2060574365
|
--- !u!23 &2060574365
|
||||||
MeshRenderer:
|
MeshRenderer:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@@ -9,21 +9,20 @@ public class PlayerMovement : MonoBehaviour
|
|||||||
public float jumpForce = 1f;
|
public float jumpForce = 1f;
|
||||||
public float gravityMultiplier = 1f;
|
public float gravityMultiplier = 1f;
|
||||||
|
|
||||||
Rigidbody rb;
|
|
||||||
CharacterController characterController;
|
CharacterController characterController;
|
||||||
[SerializeField] bool isCrouching = false;
|
[SerializeField] bool isCrouching = false;
|
||||||
Vector3 charControllerCenter;
|
Vector3 gravityVelocity;
|
||||||
|
bool grounded;
|
||||||
|
|
||||||
void Start() {
|
void Start() {
|
||||||
rb = GetComponent<Rigidbody>();
|
|
||||||
characterController = GetComponent<CharacterController>();
|
characterController = GetComponent<CharacterController>();
|
||||||
charControllerCenter = characterController.center;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update() {
|
void Update() {
|
||||||
|
grounded = characterController.isGrounded;
|
||||||
HandleCrouching();
|
HandleCrouching();
|
||||||
HandleJumping();
|
|
||||||
HandleMovement();
|
HandleMovement();
|
||||||
|
HandleJumping();
|
||||||
DoGravity();
|
DoGravity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,13 +36,13 @@ public class PlayerMovement : MonoBehaviour
|
|||||||
characterController.height /= crouchHeightMultiplier;
|
characterController.height /= crouchHeightMultiplier;
|
||||||
characterController.center -= Vector3.down * (characterController.height * (1 - crouchHeightMultiplier)) / 2;
|
characterController.center -= Vector3.down * (characterController.height * (1 - crouchHeightMultiplier)) / 2;
|
||||||
}
|
}
|
||||||
if (characterController.isGrounded) rb.AddForce(Vector3.up * (characterController.height / 5), ForceMode.VelocityChange);
|
// if (characterController.isGrounded) rb.AddForce(Vector3.up * (characterController.height / 5), ForceMode.VelocityChange);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleJumping() {
|
void HandleJumping() {
|
||||||
if (Input.GetKeyDown(KeyCode.Space) && characterController.isGrounded) {
|
if (Input.GetKeyDown(KeyCode.Space) && grounded) {
|
||||||
rb.AddForce(Vector3.up * jumpForce, ForceMode.VelocityChange);
|
gravityVelocity = Vector3.up * (jumpForce * gravityMultiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,8 +58,9 @@ public class PlayerMovement : MonoBehaviour
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DoGravity() {
|
void DoGravity() {
|
||||||
characterController.Move(rb.linearVelocity * (gravityMultiplier * Time.deltaTime));
|
if (grounded && gravityVelocity.y < 0) gravityVelocity = Vector3.down * 0.5f;
|
||||||
if (characterController.isGrounded) rb.linearVelocity *= 0.2f;
|
gravityVelocity += Physics.gravity * Time.deltaTime;
|
||||||
|
characterController.Move(gravityVelocity * (Time.deltaTime * gravityMultiplier));
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnControllerColliderHit(ControllerColliderHit hit) {
|
void OnControllerColliderHit(ControllerColliderHit hit) {
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
%YAML 1.1
|
|
||||||
%TAG !u! tag:unity3d.com,2011:
|
|
||||||
--- !u!162 &1
|
|
||||||
EditorUserSettings:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
serializedVersion: 4
|
|
||||||
m_ConfigSettings:
|
|
||||||
GraphicsSettingsInspector_UserSettings:
|
|
||||||
value: 18134705175a055722080a3115371d4a0d55006876786860616b0471b8b07a68ffab74f9ee2a3a30300cea1a11320d0beb1a0c25f7060f494b4cc80018eb09361fc211cb1f862d19c51d19dcc413d6ade0d8ddfcddf9f4d9d29195fcfde6ebeae6f0a9c9afa6f8c5b89ff7a1aacececac4eba4d7c9d28bda
|
|
||||||
flags: 0
|
|
||||||
RecentlyUsedSceneGuid-0:
|
|
||||||
value: 5a08575f5207595a0f5d59741173094444164f7d7d2a23317c7a4465bbe1646d
|
|
||||||
flags: 0
|
|
||||||
RecentlyUsedSceneGuid-1:
|
|
||||||
value: 5550035401075e09590d547640255b44411619287f2923317c7a4b37b1b1663e
|
|
||||||
flags: 0
|
|
||||||
vcSharedLogLevel:
|
|
||||||
value: 0d5e400f0650
|
|
||||||
flags: 0
|
|
||||||
m_VCAutomaticAdd: 1
|
|
||||||
m_VCDebugCom: 0
|
|
||||||
m_VCDebugCmd: 0
|
|
||||||
m_VCDebugOut: 0
|
|
||||||
m_SemanticMergeMode: 2
|
|
||||||
m_DesiredImportWorkerCount: 4
|
|
||||||
m_StandbyImportWorkerCount: 2
|
|
||||||
m_IdleImportWorkerShutdownDelay: 60000
|
|
||||||
m_VCShowFailedCheckout: 1
|
|
||||||
m_VCOverwriteFailedCheckoutAssets: 1
|
|
||||||
m_VCProjectOverlayIcons: 1
|
|
||||||
m_VCHierarchyOverlayIcons: 1
|
|
||||||
m_VCOtherOverlayIcons: 1
|
|
||||||
m_VCAllowAsyncUpdate: 1
|
|
||||||
m_VCScanLocalPackagesOnConnect: 1
|
|
||||||
m_ArtifactGarbageCollection: 1
|
|
||||||
m_CompressAssetsOnImport: 1
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "Assets",
|
|
||||||
"roots": ["Assets"],
|
|
||||||
"includes": [],
|
|
||||||
"excludes": ["Assets/Temp/", "Assets/External/"],
|
|
||||||
"options": {
|
|
||||||
"types": true,
|
|
||||||
"properties": true,
|
|
||||||
"extended": false,
|
|
||||||
"dependencies": true
|
|
||||||
},
|
|
||||||
"baseScore": 999
|
|
||||||
}
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
trackSelection = true
|
|
||||||
refreshSearchWindowsInPlayMode = false
|
|
||||||
pickerAdvancedUI = false
|
|
||||||
fetchPreview = true
|
|
||||||
defaultFlags = 0
|
|
||||||
keepOpen = true
|
|
||||||
queryFolder = "Assets"
|
|
||||||
onBoardingDoNotAskAgain = true
|
|
||||||
showPackageIndexes = false
|
|
||||||
showStatusBar = false
|
|
||||||
scopes = {
|
|
||||||
}
|
|
||||||
providers = {
|
|
||||||
asset = {
|
|
||||||
active = true
|
|
||||||
priority = 25
|
|
||||||
defaultAction = null
|
|
||||||
}
|
|
||||||
scene = {
|
|
||||||
active = true
|
|
||||||
priority = 50
|
|
||||||
defaultAction = null
|
|
||||||
}
|
|
||||||
adb = {
|
|
||||||
active = false
|
|
||||||
priority = 2500
|
|
||||||
defaultAction = null
|
|
||||||
}
|
|
||||||
presets_provider = {
|
|
||||||
active = false
|
|
||||||
priority = -10
|
|
||||||
defaultAction = null
|
|
||||||
}
|
|
||||||
find = {
|
|
||||||
active = true
|
|
||||||
priority = 25
|
|
||||||
defaultAction = null
|
|
||||||
}
|
|
||||||
packages = {
|
|
||||||
active = false
|
|
||||||
priority = 90
|
|
||||||
defaultAction = null
|
|
||||||
}
|
|
||||||
performance = {
|
|
||||||
active = false
|
|
||||||
priority = 100
|
|
||||||
defaultAction = null
|
|
||||||
}
|
|
||||||
profilermarkers = {
|
|
||||||
active = false
|
|
||||||
priority = 100
|
|
||||||
defaultAction = null
|
|
||||||
}
|
|
||||||
store = {
|
|
||||||
active = false
|
|
||||||
priority = 100
|
|
||||||
defaultAction = null
|
|
||||||
}
|
|
||||||
log = {
|
|
||||||
active = false
|
|
||||||
priority = 210
|
|
||||||
defaultAction = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
objectSelectors = {
|
|
||||||
}
|
|
||||||
recentSearches = [
|
|
||||||
]
|
|
||||||
searchItemFavorites = [
|
|
||||||
]
|
|
||||||
savedSearchesSortOrder = 0
|
|
||||||
showSavedSearchPanel = false
|
|
||||||
hideTabs = false
|
|
||||||
expandedQueries = [
|
|
||||||
]
|
|
||||||
queryBuilder = true
|
|
||||||
ignoredProperties = "id;name;classname;imagecontentshash"
|
|
||||||
helperWidgetCurrentArea = "all"
|
|
||||||
disabledIndexers = ""
|
|
||||||
minIndexVariations = 2
|
|
||||||
findProviderIndexHelper = true
|
|
||||||
Reference in New Issue
Block a user