Skip to content

Commit

Permalink
Player Controller
Browse files Browse the repository at this point in the history
  • Loading branch information
7ubi committed May 9, 2021
1 parent 4cfd781 commit 4af52a3
Show file tree
Hide file tree
Showing 27 changed files with 470 additions and 1,095 deletions.
10 changes: 5 additions & 5 deletions Assets/Chunck.mat
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Material:
m_PrefabAsset: {fileID: 0}
m_Name: Chunck
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_ShaderKeywords: _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
Expand Down Expand Up @@ -40,7 +40,7 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 5f88004ff14e4974eba3ec0705cdbef6, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
Expand All @@ -61,19 +61,19 @@ Material:
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _GlossMapScale: 0
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SmoothnessTextureChannel: 1
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 0.55006117, g: 1, b: 0.4481132, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []
8 changes: 8 additions & 0 deletions Assets/Images.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Images/dirt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
96 changes: 96 additions & 0 deletions Assets/Images/dirt.png.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 31 additions & 11 deletions Assets/Scenes/SampleScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_LocalRotation: {x: 0.29292405, y: 0.40503132, z: -0.13877745, w: 0.8549187}
m_LocalPosition: {x: -7.51, y: 34.27, z: -5.97}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0.5, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 37.826, y: 50.7, z: 0}
m_Father: {fileID: 1743702928}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1731320881
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -332,6 +332,7 @@ MonoBehaviour:
Size: 16
maxHeight: 15
seed: 69
Chunck: {fileID: 8451236987504973569, guid: 320c3e7c5fc352247932ecdea37a94a4, type: 3}
--- !u!4 &1731320883
Transform:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -359,13 +360,14 @@ GameObject:
- component: {fileID: 1743702926}
- component: {fileID: 1743702925}
- component: {fileID: 1743702929}
- component: {fileID: 1743702930}
m_Layer: 0
m_Name: Capsule
m_Name: Player
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!136 &1743702925
CapsuleCollider:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -438,11 +440,12 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1743702924}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 1, y: 18, z: 1}
m_LocalPosition: {x: 0.5, y: 6.5, z: 4.5}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Children:
- {fileID: 963194228}
m_Father: {fileID: 0}
m_RootOrder: 3
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!54 &1743702929
Rigidbody:
Expand All @@ -458,5 +461,22 @@ Rigidbody:
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 0
m_Constraints: 80
m_CollisionDetection: 0
--- !u!114 &1743702930
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1743702924}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 74bd70de0451f3c41bcc93f80c2062ea, type: 3}
m_Name:
m_EditorClassIdentifier:
moveSpeed: 5
_camera: {fileID: 963194227}
speedH: 2
speedV: 2
jumpForce: 7
49 changes: 49 additions & 0 deletions Assets/Scripts/PlayerController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
[SerializeField] private float moveSpeed;
[SerializeField] private Camera _camera;
[SerializeField] private float speedH = 2.0f;
[SerializeField] private float speedV = 2.0f;
[SerializeField] private float jumpForce;

private float _yaw = 0.0f;
private float _pitch = 0.0f;

private Rigidbody _rb;

private void Start()
{
_rb = GetComponent<Rigidbody>();
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}

private void Update()
{
var forward = Input.GetAxis("Vertical") * moveSpeed;
var right = Input.GetAxis("Horizontal") * moveSpeed;
transform.position += transform.forward * (forward * Time.deltaTime) + transform.right * (right * Time.deltaTime);

var mouseRight = Input.GetAxis("Mouse X");
var mouseUp = Input.GetAxis("Mouse Y");


_yaw += speedH * Input.GetAxis("Mouse X");
_pitch -= speedV * Input.GetAxis("Mouse Y");

if (_pitch > 90)
_pitch = 90;
if (_pitch < -90)
_pitch = -90;

transform.eulerAngles = new Vector3(0.0f, _yaw, 0.0f);
_camera.transform.eulerAngles = new Vector3(_pitch, _yaw, 0.0f);

if (Input.GetKey(KeyCode.Space) && _rb.velocity.y == 0)
_rb.velocity = new Vector3(_rb.velocity.x, jumpForce, _rb.velocity.z);
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 0 additions & 63 deletions Assets/Scripts/block.cs

This file was deleted.

Loading

0 comments on commit 4af52a3

Please sign in to comment.