From 9f2b1ff5d61f8ceff0ad1bfd8b82cdda99854650 Mon Sep 17 00:00:00 2001 From: Playmaker1210 Date: Fri, 15 Jul 2022 14:31:37 +0200 Subject: [PATCH] Jump added --- Assets/Scenes/Main.unity | 27 +- Assets/Scripts/CameraController.cs | 19 ++ Assets/Scripts/CameraController.cs.meta | 11 + Assets/Scripts/Movement.cs | 26 -- Assets/Scripts/PlayerController.cs | 42 +++ ...ement.cs.meta => PlayerController.cs.meta} | 0 ProjectSettings/InputManager.asset | 3 +- UpgradeLog.htm | 273 ------------------ UserSettings/Layouts/default-2021.dwlt | 48 +-- 9 files changed, 118 insertions(+), 331 deletions(-) create mode 100644 Assets/Scripts/CameraController.cs create mode 100644 Assets/Scripts/CameraController.cs.meta delete mode 100644 Assets/Scripts/Movement.cs create mode 100644 Assets/Scripts/PlayerController.cs rename Assets/Scripts/{Movement.cs.meta => PlayerController.cs.meta} (100%) delete mode 100644 UpgradeLog.htm diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index de4da59..37c9813 100644 --- a/Assets/Scenes/Main.unity +++ b/Assets/Scenes/Main.unity @@ -527,6 +527,7 @@ GameObject: - component: {fileID: 963194228} - component: {fileID: 963194227} - component: {fileID: 963194226} + - component: {fileID: 963194229} m_Layer: 0 m_Name: Main Camera m_TagString: MainCamera @@ -592,14 +593,27 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 963194225} - m_LocalRotation: {x: -0.34271878, y: 0.0005611182, z: -0.00020496178, w: -0.93943787} - m_LocalPosition: {x: 4.894763, y: 8.347612, z: -8.222608} + m_LocalRotation: {x: 0.38268337, y: -0.00054823596, z: 0.00022708677, w: 0.92387944} + m_LocalPosition: {x: 8.406, y: 4.7, z: -1.148} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_LocalEulerAnglesHint: {x: 45, y: -0.068, z: 0} +--- !u!114 &963194229 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 963194225} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: be9660cc0d9627849873ca175d296a63, type: 3} + m_Name: + m_EditorClassIdentifier: + player: {fileID: 1286409040} --- !u!1 &1145553048 GameObject: m_ObjectHideFlags: 0 @@ -747,11 +761,10 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: cb738793c052dd54597cff2d5ea33de3, type: 3} m_Name: m_EditorClassIdentifier: - moveSpeed: 5 - direction: {x: 0, y: 0, z: 0} + moveSpeed: 250 + jumpforce: 350 rb: {fileID: 1286409046} - horizontal: 0 - vertical: 0 + isJumping: 0 --- !u!54 &1286409046 Rigidbody: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/CameraController.cs b/Assets/Scripts/CameraController.cs new file mode 100644 index 0000000..3c0c9fc --- /dev/null +++ b/Assets/Scripts/CameraController.cs @@ -0,0 +1,19 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class CameraController : MonoBehaviour +{ + public GameObject player; + private Vector3 offset; + + void Start() + { + offset = transform.position - player.transform.position; + } + + void LateUpdate() + { + transform.position = player.transform.position + offset; + } +} diff --git a/Assets/Scripts/CameraController.cs.meta b/Assets/Scripts/CameraController.cs.meta new file mode 100644 index 0000000..0d3fb51 --- /dev/null +++ b/Assets/Scripts/CameraController.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: be9660cc0d9627849873ca175d296a63 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Movement.cs b/Assets/Scripts/Movement.cs deleted file mode 100644 index 8fce0b1..0000000 --- a/Assets/Scripts/Movement.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Movement : MonoBehaviour -{ - public float moveSpeed = 5f; - private Vector3 direction; - public Rigidbody rb; - private float horizontal, vertical; - - private void Awake() { - rb = GetComponent(); - } - - // Update is called once per frame - void Update() - { - horizontal = Input.GetAxis("Horizontal"); - vertical = Input.GetAxis("Vertical"); - - direction = new Vector3(horizontal, 0,vertical); - - rb.AddForce(direction * moveSpeed); - } -} diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs new file mode 100644 index 0000000..1435e16 --- /dev/null +++ b/Assets/Scripts/PlayerController.cs @@ -0,0 +1,42 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PlayerController : MonoBehaviour +{ + public float moveSpeed = 5f; + public float jumpforce = 5f; + private Vector3 direction; + public Rigidbody rb; + private float horizontal, vertical; + public float isJumping; + private bool isOnGround; + + + private void Awake() { + rb = GetComponent(); + } + + // Update is called once per frame + void Update() + { + horizontal = Input.GetAxis("Horizontal"); + vertical = Input.GetAxis("Vertical"); + isJumping = Input.GetAxis("Jump"); + + if (isJumping > 0 && isOnGround) { + rb.AddForce(new Vector3(horizontal, jumpforce, vertical)); + isOnGround = false; + } + + direction = new Vector3(horizontal, 0,vertical); + + rb.AddForce(direction * moveSpeed * Time.deltaTime); + } + + private void OnCollisionEnter(Collision collision) { + if (collision.collider.CompareTag("Ground")) { + isOnGround = true; + } + } +} diff --git a/Assets/Scripts/Movement.cs.meta b/Assets/Scripts/PlayerController.cs.meta similarity index 100% rename from Assets/Scripts/Movement.cs.meta rename to Assets/Scripts/PlayerController.cs.meta diff --git a/ProjectSettings/InputManager.asset b/ProjectSettings/InputManager.asset index 17c8f53..ea6e265 100644 --- a/ProjectSettings/InputManager.asset +++ b/ProjectSettings/InputManager.asset @@ -234,7 +234,7 @@ InputManager: descriptiveName: descriptiveNegativeName: negativeButton: - positiveButton: joystick button 3 + positiveButton: joystick button 0 altNegativeButton: altPositiveButton: gravity: 1000 @@ -293,3 +293,4 @@ InputManager: type: 0 axis: 0 joyNum: 0 + m_UsePhysicalKeys: 0 diff --git a/UpgradeLog.htm b/UpgradeLog.htm deleted file mode 100644 index 848eb65..0000000 --- a/UpgradeLog.htm +++ /dev/null @@ -1,273 +0,0 @@ - - - - Migration Report -

- Migration Report -

\ No newline at end of file diff --git a/UserSettings/Layouts/default-2021.dwlt b/UserSettings/Layouts/default-2021.dwlt index 2dc9afb..45fa9b0 100644 --- a/UserSettings/Layouts/default-2021.dwlt +++ b/UserSettings/Layouts/default-2021.dwlt @@ -43,8 +43,8 @@ MonoBehaviour: y: 0 width: 709 height: 386 - m_MinSize: {x: 100, y: 100} - m_MaxSize: {x: 4000, y: 4000} + m_MinSize: {x: 102, y: 121} + m_MaxSize: {x: 4002, y: 4021} m_ActualView: {fileID: 19} m_Panes: - {fileID: 19} @@ -74,7 +74,7 @@ MonoBehaviour: m_MinSize: {x: 200, y: 100} m_MaxSize: {x: 16192, y: 8096} vertical: 0 - controlID: 102 + controlID: 93 --- !u!114 &4 MonoBehaviour: m_ObjectHideFlags: 52 @@ -99,7 +99,7 @@ MonoBehaviour: m_MinSize: {x: 300, y: 200} m_MaxSize: {x: 24288, y: 16192} vertical: 0 - controlID: 28 + controlID: 52 --- !u!114 &5 MonoBehaviour: m_ObjectHideFlags: 52 @@ -273,7 +273,7 @@ MonoBehaviour: m_MinSize: {x: 200, y: 200} m_MaxSize: {x: 16192, y: 16192} vertical: 1 - controlID: 29 + controlID: 53 --- !u!114 &12 MonoBehaviour: m_ObjectHideFlags: 52 @@ -298,7 +298,7 @@ MonoBehaviour: m_MinSize: {x: 200, y: 100} m_MaxSize: {x: 16192, y: 8096} vertical: 0 - controlID: 30 + controlID: 54 --- !u!114 &13 MonoBehaviour: m_ObjectHideFlags: 52 @@ -309,7 +309,7 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 1 m_Script: {fileID: 12006, guid: 0000000000000000e000000000000000, type: 0} - m_Name: SceneView + m_Name: GameView m_EditorClassIdentifier: m_Children: [] m_Position: @@ -318,14 +318,14 @@ MonoBehaviour: y: 0 width: 1249 height: 561 - m_MinSize: {x: 202, y: 221} - m_MaxSize: {x: 4002, y: 4021} - m_ActualView: {fileID: 17} + m_MinSize: {x: 200, y: 200} + m_MaxSize: {x: 4000, y: 4000} + m_ActualView: {fileID: 18} m_Panes: - {fileID: 17} - {fileID: 18} - m_Selected: 0 - m_LastSelected: 1 + m_Selected: 1 + m_LastSelected: 0 --- !u!114 &14 MonoBehaviour: m_ObjectHideFlags: 52 @@ -380,9 +380,9 @@ MonoBehaviour: m_IsLocked: 0 m_FolderTreeState: scrollPos: {x: 0, y: 0} - m_SelectedIDs: 725a0000 - m_LastClickedID: 23154 - m_ExpandedIDs: 00000000645a0000 + m_SelectedIDs: 705a0000 + m_LastClickedID: 23152 + m_ExpandedIDs: 00000000625a0000 m_RenameOverlay: m_UserAcceptedRename: 0 m_Name: @@ -410,7 +410,7 @@ MonoBehaviour: scrollPos: {x: 0, y: 0} m_SelectedIDs: m_LastClickedID: 0 - m_ExpandedIDs: 00000000645a0000 + m_ExpandedIDs: 00000000625a0000 m_RenameOverlay: m_UserAcceptedRename: 0 m_Name: @@ -540,7 +540,7 @@ MonoBehaviour: scrollPos: {x: 0, y: 0} m_SelectedIDs: m_LastClickedID: 0 - m_ExpandedIDs: 3afbffffd8590000ee590000f2590000 + m_ExpandedIDs: 3afbffff m_RenameOverlay: m_UserAcceptedRename: 0 m_Name: @@ -673,7 +673,7 @@ MonoBehaviour: containerId: overlay-container--right floating: 0 collapsed: 0 - displayed: 0 + displayed: 1 snapOffset: {x: 0, y: 0} snapOffsetDelta: {x: 0, y: 0} snapCorner: 0 @@ -789,9 +789,9 @@ MonoBehaviour: m_PlayAudio: 0 m_AudioPlay: 0 m_Position: - m_Target: {x: 4.8806105, y: -1.6259584, z: 3.6275797} + m_Target: {x: 4.2956486, y: 2.0538712, z: 3.4216719} speed: 2 - m_Value: {x: 4.8806105, y: -1.6259584, z: 3.6275797} + m_Value: {x: 4.2956486, y: 2.0538712, z: 3.4216719} m_RenderMode: 0 m_CameraMode: drawMode: 0 @@ -842,9 +842,9 @@ MonoBehaviour: speed: 2 m_Value: {x: -0.34271884, y: 0.0005610483, z: -0.00020494121, w: -0.9394379} m_Size: - m_Target: 7.7443404 + m_Target: 4.338933 speed: 2 - m_Value: 7.7443404 + m_Value: 4.338933 m_Ortho: m_Target: 0 speed: 2 @@ -911,7 +911,7 @@ MonoBehaviour: m_UseMipMap: 0 m_VSyncEnabled: 0 m_Gizmos: 0 - m_Stats: 0 + m_Stats: 1 m_SelectedSizes: 00000000000000000000000000000000000000000000000000000000000000000000000000000000 m_ZoomArea: m_HRangeLocked: 0 @@ -930,7 +930,7 @@ MonoBehaviour: m_HSlider: 0 m_VSlider: 0 m_IgnoreScrollWheelUntilClicked: 0 - m_EnableMouseInput: 0 + m_EnableMouseInput: 1 m_EnableSliderZoomHorizontal: 0 m_EnableSliderZoomVertical: 0 m_UniformScale: 1