Compare commits

...
6 changed files with 3991 additions and 64 deletions
+77
View File
@@ -0,0 +1,77 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Test Checker
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 5, y: 5}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 10309, guid: 0000000000000000f000000000000000, type: 0}
m_Scale: {x: 5, y: 5}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 022ba1843dfdcfe4a832a7fcfd80c6fa
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 2bd92030de793ce408d33ee279c593fc
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+49 -15
View File
@@ -10,20 +10,31 @@ using System.Collections;
public class PlayerController : MonoBehaviour
{
CharacterController characterController;
CapsuleCollider capsule;
public float speed;
public float jumpSpeed;
public float jumpHeight;
public float gravity;
public float rotationSpeed;
public Transform pivot;
public GameObject playerModel;
private bool extraJump = true;
private int jump = 0;
private float capsuleHeight;
private float controllerHeight;
private float transformHeight;
private Vector3 moveDirection;
float startTime = 0.0f;
float oneSec = 1.0f;
void Start()
{
characterController = GetComponent<CharacterController>();
capsule = GetComponent<CapsuleCollider>();
transformHeight = transform.localScale.y;
controllerHeight = characterController.height;
capsuleHeight = capsule.height;
}
void Update()
@@ -33,11 +44,10 @@ public class PlayerController : MonoBehaviour
//Need to switch to 'raw' when using keyboard
moveDirection = (transform.forward * Input.GetAxis("Vertical")) + (transform.right * Input.GetAxis("Horizontal"));
if (extraJump == true)
if (jump <= 1)
{
moveDirection = moveDirection.normalized * speed; //Remove this line to make running diagonal the fastest standard run
} else
{
} else {
moveDirection = (moveDirection.normalized * speed)/4; //Remove this line to make running diagonal the fastest standard run
}
@@ -45,7 +55,7 @@ public class PlayerController : MonoBehaviour
if (characterController.isGrounded)
{
extraJump = true;
jump = 0;
moveDirection.y = 0.0f;
if(Input.GetKey(KeyCode.LeftShift))
@@ -55,21 +65,45 @@ public class PlayerController : MonoBehaviour
moveDirection = moveDirection.normalized * speed;
}
if (Input.GetButtonDown("Jump"))
if(Input.GetKey(KeyCode.LeftControl))
{
moveDirection.y = jumpSpeed;
characterController.height /= 2;
capsule.height /= 2;
transform.localScale = new Vector3(transform.localScale.x, transformHeight/2, transform.localScale.z);
if(Input.GetKeyDown(KeyCode.LeftControl))
{
startTime = Time.time;
}
if(characterController.velocity != new Vector3(0, 0, 0) && startTime + oneSec >= Time.time)
{
moveDirection = (moveDirection.normalized * speed * 2);
} else {
moveDirection = (moveDirection.normalized * speed/4);
}
} else {
moveDirection = moveDirection.normalized * speed;
characterController.height = controllerHeight;
capsule.height = capsuleHeight;
transform.localScale = new Vector3(transform.localScale.x, transformHeight, transform.localScale.z);
}
} else {
if (Input.GetButtonDown("Jump") && extraJump == true)
{
moveDirection.y = jumpSpeed;
extraJump = false;
}
}
if (Input.GetButtonDown("Jump") && jump <= 1)
{
moveDirection.y = jumpHeight;
jump++;
}
moveDirection.y = moveDirection.y + (Physics.gravity.y * gravity * Time.deltaTime);
moveDirection.y += Physics.gravity.y * gravity * Time.deltaTime;
// Move the controller
characterController.Move(moveDirection * Time.deltaTime);