Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
706ad21ed1 |
@@ -1,77 +0,0 @@
|
||||
%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}
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 022ba1843dfdcfe4a832a7fcfd80c6fa
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+58
-1563
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2bd92030de793ce408d33ee279c593fc
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -9,53 +9,48 @@ using System.Collections;
|
||||
|
||||
public class PlayerController : MonoBehaviour
|
||||
{
|
||||
CharacterController characterController;
|
||||
CapsuleCollider capsule;
|
||||
Rigidbody rb;
|
||||
|
||||
public float speed;
|
||||
public float jumpHeight;
|
||||
public float jumpSpeed;
|
||||
public float gravity;
|
||||
public float rotationSpeed;
|
||||
public Transform pivot;
|
||||
public GameObject playerModel;
|
||||
|
||||
private int jump = 0;
|
||||
private float capsuleHeight;
|
||||
private float controllerHeight;
|
||||
private float transformHeight;
|
||||
private bool extraJump = true;
|
||||
private float distToGround;
|
||||
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;
|
||||
rb = GetComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
bool IsGrounded(){
|
||||
return Physics.Raycast(transform.position, -Vector3.up, distToGround + 0.1f);
|
||||
}
|
||||
|
||||
void FixedUpdate()
|
||||
{
|
||||
|
||||
float yStore = moveDirection.y;
|
||||
//Need to switch to 'raw' when using keyboard
|
||||
moveDirection = (transform.forward * Input.GetAxis("Vertical")) + (transform.right * Input.GetAxis("Horizontal"));
|
||||
|
||||
if (jump <= 1)
|
||||
if (extraJump == true)
|
||||
{
|
||||
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
|
||||
}
|
||||
|
||||
moveDirection.y = yStore;
|
||||
|
||||
if (characterController.isGrounded)
|
||||
if (IsGrounded())
|
||||
{
|
||||
jump = 0;
|
||||
extraJump = true;
|
||||
moveDirection.y = 0.0f;
|
||||
|
||||
if(Input.GetKey(KeyCode.LeftShift))
|
||||
@@ -65,48 +60,24 @@ public class PlayerController : MonoBehaviour
|
||||
moveDirection = moveDirection.normalized * speed;
|
||||
}
|
||||
|
||||
if(Input.GetKey(KeyCode.LeftControl))
|
||||
if (Input.GetButtonDown("Jump"))
|
||||
{
|
||||
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 += Physics.gravity.y * gravity * Time.deltaTime;
|
||||
moveDirection.y = moveDirection.y + (Physics.gravity.y * gravity * Time.deltaTime);
|
||||
|
||||
// Move the controller
|
||||
characterController.Move(moveDirection * Time.deltaTime);
|
||||
rb.AddForce(moveDirection * Time.deltaTime);
|
||||
|
||||
//Move the player in different directions based on camera look direction
|
||||
//Need to switch to 'raw' when using keyboard
|
||||
|
||||
Reference in New Issue
Block a user