-
Notifications
You must be signed in to change notification settings - Fork 0
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c22728b
Merge pull request #2 from jond2003/develop
jond2003 d1e6373
Implemented player movement and looking
EthanYeung513 a688b92
Merge pull request #4 from jond2003/PlayerBaseControls
EthanYeung513 36c2751
fix player not moving with current rotation
EthanYeung513 da027b6
Merge pull request #6 from jond2003/PlayerBaseControls
EthanYeung513 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,281 @@ | ||
%YAML 1.1 | ||
%TAG !u! tag:unity3d.com,2011: | ||
--- !u!1 &2289027266630935537 | ||
GameObject: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
serializedVersion: 6 | ||
m_Component: | ||
- component: {fileID: 1553699941529852627} | ||
- component: {fileID: 5982566117195255381} | ||
- component: {fileID: 3394700572081707293} | ||
- component: {fileID: 6095684379653718213} | ||
- component: {fileID: 7838910914143989060} | ||
- component: {fileID: 4194105926190900469} | ||
m_Layer: 0 | ||
m_Name: Player | ||
m_TagString: Untagged | ||
m_Icon: {fileID: 0} | ||
m_NavMeshLayer: 0 | ||
m_StaticEditorFlags: 0 | ||
m_IsActive: 1 | ||
--- !u!4 &1553699941529852627 | ||
Transform: | ||
m_ObjectHideFlags: 0 | 10000||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 2289027266630935537} | ||
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: 2951051746932321162} | ||
m_Father: {fileID: 0} | ||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} | ||
--- !u!33 &5982566117195255381 | ||
MeshFilter: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 2289027266630935537} | ||
m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0} | ||
--- !u!23 &3394700572081707293 | ||
MeshRenderer: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 2289027266630935537} | ||
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_RenderingLayerMask: 1 | ||
m_RendererPriority: 0 | ||
m_Materials: | ||
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} | ||
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_SortingLayerID: 0 | ||
m_SortingLayer: 0 | ||
m_SortingOrder: 0 | ||
m_AdditionalVertexStreams: {fileID: 0} | ||
--- !u!136 &6095684379653718213 | ||
CapsuleCollider: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 2289027266630935537} | ||
m_Material: {fileID: 0} | ||
m_IncludeLayers: | ||
serializedVersion: 2 | ||
m_Bits: 0 | ||
m_ExcludeLayers: | ||
serializedVersion: 2 | ||
m_Bits: 0 | ||
m_LayerOverridePriority: 0 | ||
m_IsTrigger: 0 | ||
m_ProvidesContacts: 0 | ||
m_Enabled: 1 | ||
serializedVersion: 2 | ||
m_Radius: 0.5 | ||
m_Height: 2 | ||
m_Direction: 1 | ||
m_Center: {x: 0, y: 0, z: 0} | ||
--- !u!114 &7838910914143989060 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 2289027266630935537} | ||
m_Enabled: 1 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 11500000, guid: 62899f850307741f2a39c98a8b639597, type: 3} | ||
m_Name: | ||
m_EditorClassIdentifier: | ||
m_Actions: {fileID: -944628639613478452, guid: 3b42f69ecb5ba9448bf4259468d13fb7, type: 3} | ||
m_NotificationBehavior: 0 | ||
m_UIInputModule: {fileID: 0} | ||
m_DeviceLostEvent: | ||
m_PersistentCalls: | ||
m_Calls: [] | ||
m_DeviceRegainedEvent: | ||
m_PersistentCalls: | ||
m_Calls: [] | ||
m_ControlsChangedEvent: | ||
m_PersistentCalls: | ||
m_Calls: [] | ||
m_ActionEvents: [] | ||
m_NeverAutoSwitchControlSchemes: 0 | ||
m_DefaultControlScheme: | ||
m_DefaultActionMap: Player | ||
m_SplitScreenIndex: -1 | ||
m_Camera: {fileID: 0} | ||
--- !u!114 &4194105926190900469 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 2289027266630935537} | ||
m_Enabled: 1 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 11500000, guid: d61ed2b929769664db7769734235d810, type: 3} | ||
m_Name: | ||
m_EditorClassIdentifier: | ||
inputAxis: | ||
m_Name: Input Axis | ||
m_Type: 0 | ||
m_ExpectedControlType: | ||
m_Id: eb271c18-b4cc-45f6-b432-acd0ed1a5213 | ||
m_Processors: | ||
m_Interactions: | ||
m_SingletonActionBindings: [] | ||
m_Flags: 0 | ||
playerInput: {fileID: 7838910914143989060} | ||
playerSpeed: 8 | ||
--- !u!1 &9162915339291402840 | ||
GameObject: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
serializedVersion: 6 | ||
m_Component: | ||
- component: {fileID: 2951051746932321162} | ||
- component: {fileID: 511851105072833671} | ||
- component: {fileID: 3914663573818666684} | ||
- component: {fileID: 4647518505118886944} | ||
m_Layer: 0 | ||
m_Name: PlayerCamera | ||
m_TagString: Untagged | ||
m_Icon: {fileID: 0} | ||
m_NavMeshLayer: 0 | ||
m_StaticEditorFlags: 0 | ||
m_IsActive: 1 | ||
--- !u!4 &2951051746932321162 | ||
Transform: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 9162915339291402840} | ||
serializedVersion: 2 | ||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} | ||
m_LocalPosition: {x: 0, y: 0.842, z: 0} | ||
m_LocalScale: {x: 1, y: 1, z: 1} | ||
m_ConstrainProportionsScale: 0 | ||
m_Children: [] | ||
m_Father: {fileID: 1553699941529852627} | ||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} | ||
--- !u!20 &511851105072833671 | ||
Camera: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 9162915339291402840} | ||
m_Enabled: 1 | ||
serializedVersion: 2 | ||
m_ClearFlags: 1 | ||
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} | ||
m_projectionMatrixMode: 1 | ||
m_GateFitMode: 2 | ||
m_FOVAxisMode: 0 | ||
m_Iso: 200 | ||
m_ShutterSpeed: 0.005 | ||
m_Aperture: 16 | ||
m_FocusDistance: 10 | ||
m_FocalLength: 50 | ||
m_BladeCount: 5 | ||
m_Curvature: {x: 2, y: 11} | ||
m_BarrelClipping: 0.25 | ||
m_Anamorphism: 0 | ||
m_SensorSize: {x: 36, y: 24} | ||
m_LensShift: {x: 0, y: 0} | ||
m_NormalizedViewPortRect: | ||
serializedVersion: 2 | ||
x: 0 | ||
y: 0 | ||
width: 1 | ||
height: 1 | ||
near clip plane: 0.3 | ||
far clip plane: 1000 | ||
field of view: 60 | ||
orthographic: 0 | ||
orthographic size: 5 | ||
m_Depth: 0 | ||
m_CullingMask: | ||
serializedVersion: 2 | ||
m_Bits: 4294967295 | ||
m_RenderingPath: -1 | ||
m_TargetTexture: {fileID: 0} | ||
m_TargetDisplay: 0 | ||
m_TargetEye: 3 | ||
m_HDR: 1 | ||
m_AllowMSAA: 1 | ||
m_AllowDynamicResolution: 0 | ||
m_ForceIntoRT: 0 | ||
m_OcclusionCulling: 1 | ||
m_StereoConvergence: 10 | ||
m_StereoSeparation: 0.022 | ||
--- !u!81 &3914663573818666684 | ||
AudioListener: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 9162915339291402840} | ||
m_Enabled: 1 | ||
--- !u!114 &4647518505118886944 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 9162915339291402840} | ||
m_Enabled: 1 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 11500000, guid: 95eb5b48d696b724a892d5b978b685ad, type: 3} | ||
m_Name: | ||
m_EditorClassIdentifier: | ||
inputAxis: | ||
m_Name: Input Axis | ||
m_Type: 0 | ||
m_ExpectedControlType: | ||
m_Id: 2cb2f34d-1af5-4acd-bf67-62497debba9f | ||
m_Processors: | ||
m_Interactions: | ||
m_SingletonActionBindings: [] | ||
m_Flags: 0 | ||
playerInput: {fileID: 7838910914143989060} | ||
cameraSensitivity: 4 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.InputSystem; | ||
|
||
public class PlayerLook : MonoBehaviour | ||
{ | ||
[SerializeField] private InputAction inputAxis; | ||
[SerializeField] private PlayerInput playerInput; | ||
private Transform playerTransform; | ||
|
||
[SerializeField] private float cameraSensitivity = 4; | ||
float xRotate = 0f; | ||
|
||
void Awake() | ||
{ | ||
|
||
Cursor.lockState = CursorLockMode.Locked; //Hide cursor | ||
|
||
inputAxis = playerInput.actions.FindAction("Look"); | ||
playerTransform = transform.parent; | ||
|
||
} | ||
|
||
void FixedUpdate() | ||
{ | ||
playerLook(); | ||
} | ||
|
||
private void playerLook() | ||
{ | ||
Vector2 direction = inputAxis.ReadValue<Vector2>(); //Read mouse movement | ||
|
||
float mouseX = cameraSensitivity * direction.x * Time.deltaTime; | ||
float mouseY = cameraSensitivity * direction.y * Time.deltaTime; | ||
|
||
xRotate -= mouseY; | ||
xRotate = Mathf.Clamp(xRotate, -90f, 90f); | ||
|
||
transform.localRotation = Quaternion.Euler(xRotate, 0, 0); | ||
playerTransform.Rotate(Vector3.up * mouseX); //rotate on horizontal | ||
|
||
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Player base controls #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account