Compare commits

...
Author SHA1 Message Date
Gregory CampbellandGitHub d84d484f8f Revert "Expand test area" 2019-12-07 15:33:13 -05:00
Gregory CampbellandGitHub 7dfaa0e4df Merge pull request #13 from gjcampbell777/expand_test_area
Expand test area
2019-12-07 15:25:00 -05:00
Gregory CampbellandGitHub a6c845e6bf Merge branch 'master' into expand_test_area 2019-12-07 15:24:48 -05:00
Gregory Campbell d8608b3d1e Renamed Test Scene so it may be easier to merge 2019-12-07 13:31:17 -05:00
Gregory Campbell 9de4193758 Added more crawling/sliding obstacles and updated unity version 2019-12-07 13:21:24 -05:00
Gregory Campbell 416f976587 Added new obstacles and platforms as well as a new material for prototyping 2019-12-07 00:37:06 -05:00
Gregory CampbellandGitHub 28bcba0680 Merge pull request #12 from gjcampbell777/crawl_slide_button
Crawl slide button
2019-12-06 22:36:03 -05:00
Gregory Campbell 645395a43c Added implementation so that crawling in differentiated from sliding through current player movement 2019-12-06 22:34:57 -05:00
Gregory Campbell ba63ebf72b Added sliding which reverts back to crouching/crawling after 1 second 2019-12-05 23:17:24 -05:00
Gregory Campbell 9c10ca695d Crouching/crawling functionality is working 2019-12-05 22:42:16 -05:00
Gregory CampbellandGitHub c13613ca25 Merge pull request #11 from gjcampbell777/rework_jump_counter
Cleaned up jumping and double jumping implementation
2019-12-05 21:58:53 -05:00
Gregory Campbell 2ade04fcba Cleaned up jumping and double jumping implementation 2019-12-05 21:57:29 -05:00
Gregory Campbell 1b3bf960e4 Initial push. Floating stationary platforms added. 2019-10-02 20:43:13 -04:00
2 changed files with 57 additions and 17 deletions
+8 -2
View File
@@ -96,6 +96,7 @@ LightmapSettings:
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
--- !u!196 &4
@@ -199,6 +200,7 @@ MeshRenderer:
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
@@ -270,8 +272,9 @@ Light:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 705507993}
m_Enabled: 1
serializedVersion: 9
serializedVersion: 10
m_Type: 1
m_Shape: 0
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 1
m_Range: 10
@@ -396,6 +399,7 @@ MeshRenderer:
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
@@ -477,6 +481,7 @@ MeshRenderer:
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
@@ -537,7 +542,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
speed: 20
jumpSpeed: 20
jumpHeight: 15
gravity: 5
rotationSpeed: 20
pivot: {fileID: 1402695046}
@@ -620,6 +625,7 @@ MeshRenderer:
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
+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);