Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
93307022e4 | ||
|
|
a557887275 | ||
|
|
b9cfa34614 | ||
|
|
e6db8a979c | ||
|
|
d4fafd63d3 | ||
|
|
081d93f2c2 | ||
|
|
996e1e3b20 | ||
|
|
386b51589e | ||
|
|
573b4815ea | ||
|
|
db8ae256a8 |
@@ -180,7 +180,7 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 194035203}
|
m_GameObject: {fileID: 194035203}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 80, y: 6.5, z: 12}
|
m_LocalPosition: {x: 155, y: 6.5, z: 12}
|
||||||
m_LocalScale: {x: 75, y: 20, z: 0.25}
|
m_LocalScale: {x: 75, y: 20, z: 0.25}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 1013482115}
|
m_Father: {fileID: 1013482115}
|
||||||
@@ -273,7 +273,7 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 195913138}
|
m_GameObject: {fileID: 195913138}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 21, y: 2.5, z: -30}
|
m_LocalPosition: {x: 42, y: 2.5, z: -49.5}
|
||||||
m_LocalScale: {x: 10, y: 5, z: 10}
|
m_LocalScale: {x: 10, y: 5, z: 10}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 746704017}
|
m_Father: {fileID: 746704017}
|
||||||
@@ -366,8 +366,8 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 203887784}
|
m_GameObject: {fileID: 203887784}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 120, y: -0.5, z: 6}
|
m_LocalPosition: {x: 215, y: -0.5, z: 6}
|
||||||
m_LocalScale: {x: 20, y: 0.5, z: 12}
|
m_LocalScale: {x: 75, y: 0.5, z: 75}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 833538478}
|
m_Father: {fileID: 833538478}
|
||||||
m_RootOrder: 2
|
m_RootOrder: 2
|
||||||
@@ -459,7 +459,7 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 241158957}
|
m_GameObject: {fileID: 241158957}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: -25, y: 2, z: 22}
|
m_LocalPosition: {x: -50, y: 2, z: 45}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 5}
|
m_LocalScale: {x: 1, y: 1, z: 5}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 1488444358}
|
m_Father: {fileID: 1488444358}
|
||||||
@@ -552,7 +552,7 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 432077771}
|
m_GameObject: {fileID: 432077771}
|
||||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
m_LocalPosition: {x: -35, y: 5, z: -20}
|
m_LocalPosition: {x: -63, y: 5, z: -37}
|
||||||
m_LocalScale: {x: 10, y: 1, z: 10}
|
m_LocalScale: {x: 10, y: 1, z: 10}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 942294095}
|
m_Father: {fileID: 942294095}
|
||||||
@@ -645,7 +645,7 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 478907417}
|
m_GameObject: {fileID: 478907417}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0.38268343, w: 0.92387956}
|
m_LocalRotation: {x: 0, y: 0, z: 0.38268343, w: 0.92387956}
|
||||||
m_LocalPosition: {x: 15, y: 7, z: 40}
|
m_LocalPosition: {x: 45, y: 7, z: 60}
|
||||||
m_LocalScale: {x: 25, y: 5, z: 7}
|
m_LocalScale: {x: 25, y: 5, z: 7}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 1833724898}
|
m_Father: {fileID: 1833724898}
|
||||||
@@ -832,7 +832,7 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 654784537}
|
m_GameObject: {fileID: 654784537}
|
||||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
m_LocalPosition: {x: -25, y: 2, z: -10}
|
m_LocalPosition: {x: -53, y: 2, z: -27}
|
||||||
m_LocalScale: {x: 10, y: 1, z: 10}
|
m_LocalScale: {x: 10, y: 1, z: 10}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 942294095}
|
m_Father: {fileID: 942294095}
|
||||||
@@ -1017,7 +1017,7 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 717001268}
|
m_GameObject: {fileID: 717001268}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: -25.5, y: 2, z: 36}
|
m_LocalPosition: {x: -49, y: 2, z: 58}
|
||||||
m_LocalScale: {x: 14, y: 1, z: 7}
|
m_LocalScale: {x: 14, y: 1, z: 7}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 1488444358}
|
m_Father: {fileID: 1488444358}
|
||||||
@@ -1111,7 +1111,7 @@ Transform:
|
|||||||
m_GameObject: {fileID: 736244541}
|
m_GameObject: {fileID: 736244541}
|
||||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 100, y: 0.5, z: 100}
|
m_LocalScale: {x: 250, y: 0.5, z: 250}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 833538478}
|
m_Father: {fileID: 833538478}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
@@ -1284,9 +1284,8 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 83127dd120c01de45954b99cc4d669a5, type: 3}
|
m_Script: {fileID: 11500000, guid: 83127dd120c01de45954b99cc4d669a5, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
speed: 10
|
|
||||||
maxSpeed: 25
|
maxSpeed: 25
|
||||||
acceleration: 3
|
acceleration: 0.5
|
||||||
friction: 0.1
|
friction: 0.1
|
||||||
jumpHeight: 20
|
jumpHeight: 20
|
||||||
gravity: 5
|
gravity: 5
|
||||||
@@ -1404,7 +1403,7 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 858957125}
|
m_GameObject: {fileID: 858957125}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 80, y: 6.5, z: 0}
|
m_LocalPosition: {x: 155, y: 6.5, z: 0}
|
||||||
m_LocalScale: {x: 75, y: 20, z: 0.25}
|
m_LocalScale: {x: 75, y: 20, z: 0.25}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 1013482115}
|
m_Father: {fileID: 1013482115}
|
||||||
@@ -1667,7 +1666,7 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1194166061}
|
m_GameObject: {fileID: 1194166061}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: -36, y: 2, z: 25.5}
|
m_LocalPosition: {x: -59.5, y: 2, z: 47.5}
|
||||||
m_LocalScale: {x: 7, y: 1, z: 14}
|
m_LocalScale: {x: 7, y: 1, z: 14}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 1488444358}
|
m_Father: {fileID: 1488444358}
|
||||||
@@ -1824,7 +1823,7 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1509260413}
|
m_GameObject: {fileID: 1509260413}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 28, y: 5, z: -23}
|
m_LocalPosition: {x: 49, y: 5, z: -42.5}
|
||||||
m_LocalScale: {x: 10, y: 10, z: 10}
|
m_LocalScale: {x: 10, y: 10, z: 10}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 746704017}
|
m_Father: {fileID: 746704017}
|
||||||
@@ -1917,7 +1916,7 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1810553729}
|
m_GameObject: {fileID: 1810553729}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: -22, y: 2, z: 25}
|
m_LocalPosition: {x: -47, y: 2, z: 48}
|
||||||
m_LocalScale: {x: 5, y: 1, z: 1}
|
m_LocalScale: {x: 5, y: 1, z: 1}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 1488444358}
|
m_Father: {fileID: 1488444358}
|
||||||
@@ -2045,7 +2044,7 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1853948297}
|
m_GameObject: {fileID: 1853948297}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 80, y: -3.5, z: 6}
|
m_LocalPosition: {x: 155, y: -3.5, z: 6}
|
||||||
m_LocalScale: {x: 75, y: 0.25, z: 12}
|
m_LocalScale: {x: 75, y: 0.25, z: 12}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 833538478}
|
m_Father: {fileID: 833538478}
|
||||||
@@ -2138,7 +2137,7 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1943602250}
|
m_GameObject: {fileID: 1943602250}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 19, y: 1, z: -21}
|
m_LocalPosition: {x: 40, y: 1, z: -40.5}
|
||||||
m_LocalScale: {x: 10, y: 2, z: 10}
|
m_LocalScale: {x: 10, y: 2, z: 10}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 746704017}
|
m_Father: {fileID: 746704017}
|
||||||
@@ -2231,7 +2230,7 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 2057687440}
|
m_GameObject: {fileID: 2057687440}
|
||||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
m_LocalPosition: {x: -20, y: 10, z: -30}
|
m_LocalPosition: {x: -48, y: 10, z: -47}
|
||||||
m_LocalScale: {x: 10, y: 1, z: 10}
|
m_LocalScale: {x: 10, y: 1, z: 10}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 942294095}
|
m_Father: {fileID: 942294095}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ public class PlayerController : MonoBehaviour
|
|||||||
CharacterController characterController;
|
CharacterController characterController;
|
||||||
CapsuleCollider capsule;
|
CapsuleCollider capsule;
|
||||||
|
|
||||||
public float speed;
|
|
||||||
public float maxSpeed;
|
public float maxSpeed;
|
||||||
public float acceleration;
|
public float acceleration;
|
||||||
public float friction;
|
public float friction;
|
||||||
@@ -23,9 +22,14 @@ public class PlayerController : MonoBehaviour
|
|||||||
public GameObject playerModel;
|
public GameObject playerModel;
|
||||||
|
|
||||||
private bool wallRunning = false;
|
private bool wallRunning = false;
|
||||||
|
private bool diving = false;
|
||||||
|
private bool sliding = false;
|
||||||
private int jump = 0;
|
private int jump = 0;
|
||||||
private int wall = 0;
|
private int wall = 0;
|
||||||
|
private int dive = 0;
|
||||||
private float maxSpeedStore;
|
private float maxSpeedStore;
|
||||||
|
private float maxSpeedCap = 100;
|
||||||
|
private float accelerationStore;
|
||||||
private float capsuleHeight;
|
private float capsuleHeight;
|
||||||
private float controllerHeight;
|
private float controllerHeight;
|
||||||
private float transformHeight;
|
private float transformHeight;
|
||||||
@@ -33,9 +37,13 @@ public class PlayerController : MonoBehaviour
|
|||||||
private float zVelocity = 0.0f;
|
private float zVelocity = 0.0f;
|
||||||
private Vector3 moveDirection;
|
private Vector3 moveDirection;
|
||||||
private Vector3 velocity;
|
private Vector3 velocity;
|
||||||
|
private Vector3 gravityVelocity;
|
||||||
|
|
||||||
float startTime = 0.0f;
|
float slideTime = 0.0f;
|
||||||
|
float wallRunTime = 0.0f;
|
||||||
float oneSec = 1.0f;
|
float oneSec = 1.0f;
|
||||||
|
float halfSec = 0.5f;
|
||||||
|
float quarterSec = 0.25f;
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
@@ -45,6 +53,7 @@ public class PlayerController : MonoBehaviour
|
|||||||
controllerHeight = characterController.height;
|
controllerHeight = characterController.height;
|
||||||
capsuleHeight = capsule.height;
|
capsuleHeight = capsule.height;
|
||||||
maxSpeedStore = maxSpeed;
|
maxSpeedStore = maxSpeed;
|
||||||
|
accelerationStore = acceleration;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnControllerColliderHit(ControllerColliderHit hit)
|
void OnControllerColliderHit(ControllerColliderHit hit)
|
||||||
@@ -62,81 +71,121 @@ public class PlayerController : MonoBehaviour
|
|||||||
{
|
{
|
||||||
|
|
||||||
float yStore = moveDirection.y;
|
float yStore = moveDirection.y;
|
||||||
maxSpeed = maxSpeedStore;
|
|
||||||
//Need to switch to 'raw' when using keyboard
|
|
||||||
//moveDirection = (transform.forward * Input.GetAxis("Vertical")) + (transform.right * Input.GetAxis("Horizontal"));
|
|
||||||
moveDirection = new Vector3(Input.GetAxis("Horizontal"), moveDirection.y, Input.GetAxis("Vertical"));
|
moveDirection = new Vector3(Input.GetAxis("Horizontal"), moveDirection.y, Input.GetAxis("Vertical"));
|
||||||
moveDirection = transform.TransformDirection(moveDirection);
|
moveDirection = transform.TransformDirection(moveDirection);
|
||||||
moveDirection = Vector3.ClampMagnitude(moveDirection, 1.0f);
|
moveDirection = Vector3.ClampMagnitude(moveDirection, 1.0f);
|
||||||
|
|
||||||
velocity.x += moveDirection.x * acceleration;
|
|
||||||
velocity.z += moveDirection.z * acceleration;
|
|
||||||
|
|
||||||
if (jump <= 1)
|
|
||||||
{
|
|
||||||
//moveDirection = moveDirection.normalized * speed; //Remove this line to make running diagonal the fastest standard run
|
|
||||||
//maxSpeed = maxSpeedStore;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
//moveDirection = (moveDirection.normalized * speed)/4; //Remove this line to make running diagonal the fastest standard run
|
|
||||||
maxSpeed = maxSpeedStore/2;
|
|
||||||
}
|
|
||||||
|
|
||||||
moveDirection.y = yStore;
|
moveDirection.y = yStore;
|
||||||
|
|
||||||
|
if (jump >= 2)
|
||||||
|
{
|
||||||
|
if(maxSpeed > maxSpeedStore/1.5f)
|
||||||
|
{
|
||||||
|
maxSpeed -= acceleration;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (characterController.isGrounded)
|
if (characterController.isGrounded)
|
||||||
{
|
{
|
||||||
|
diving = false;
|
||||||
|
dive = 0;
|
||||||
jump = 0;
|
jump = 0;
|
||||||
moveDirection.y = 0.0f;
|
moveDirection.y = 0.0f;
|
||||||
|
|
||||||
if(Input.GetKey(KeyCode.LeftShift))
|
if(maxSpeed > maxSpeedStore)
|
||||||
{
|
{
|
||||||
//moveDirection = (moveDirection.normalized * speed/2);
|
maxSpeed -= acceleration/5;
|
||||||
maxSpeed = maxSpeedStore/2;
|
|
||||||
} else {
|
|
||||||
//moveDirection = moveDirection.normalized * speed;
|
|
||||||
maxSpeed = maxSpeedStore;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Input.GetKey(KeyCode.LeftControl))
|
if(maxSpeed < maxSpeedStore && !Input.GetButton("Walk") && !Input.GetButton("Crouch"))
|
||||||
|
{
|
||||||
|
maxSpeed += acceleration;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Input.GetButton("Walk"))
|
||||||
|
{
|
||||||
|
if(maxSpeed > maxSpeedStore/2)
|
||||||
|
{
|
||||||
|
maxSpeed -= acceleration;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Input.GetButton("Crouch"))
|
||||||
{
|
{
|
||||||
|
|
||||||
characterController.height /= 2;
|
characterController.height /= 2;
|
||||||
capsule.height /= 2;
|
capsule.height /= 2;
|
||||||
transform.localScale = new Vector3(transform.localScale.x, transformHeight/2, transform.localScale.z);
|
transform.localScale = new Vector3(transform.localScale.x, transformHeight/2, transform.localScale.z);
|
||||||
|
|
||||||
if(Input.GetKeyDown(KeyCode.LeftControl) && characterController.velocity != new Vector3(0, 0, 0)
|
if(Input.GetButtonDown("Crouch"))
|
||||||
&& (Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0))
|
|
||||||
{
|
{
|
||||||
startTime = Time.time;
|
if((Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0))
|
||||||
|
{
|
||||||
|
sliding = true;
|
||||||
|
slideTime = Time.time;
|
||||||
|
} else {
|
||||||
|
sliding = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(startTime + oneSec >= Time.time)
|
if(slideTime + halfSec >= Time.time && sliding == true)
|
||||||
{
|
{
|
||||||
|
|
||||||
//moveDirection = (moveDirection.normalized * speed * 2);
|
if(maxSpeed < maxSpeedStore*2)
|
||||||
maxSpeed = maxSpeedStore*2;
|
{
|
||||||
|
maxSpeed += acceleration*2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Input.GetButton("Jump") && slideTime + quarterSec >= Time.time)
|
||||||
|
{
|
||||||
|
maxSpeed += 5;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
//moveDirection = (moveDirection.normalized * speed/4);
|
if(maxSpeed > maxSpeedStore/4)
|
||||||
maxSpeed = maxSpeedStore/4;
|
{
|
||||||
|
maxSpeed -= acceleration;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
moveDirection = moveDirection.normalized * speed;
|
|
||||||
characterController.height = controllerHeight;
|
characterController.height = controllerHeight;
|
||||||
capsule.height = capsuleHeight;
|
capsule.height = capsuleHeight;
|
||||||
transform.localScale = new Vector3(transform.localScale.x, transformHeight, transform.localScale.z);
|
transform.localScale = new Vector3(transform.localScale.x, transformHeight, transform.localScale.z);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else {
|
||||||
|
slideTime = Time.time;
|
||||||
|
|
||||||
if(Input.GetAxis("Horizontal") == 0 && Input.GetAxis("Vertical") == 0){
|
if(Input.GetButton("Crouch"))
|
||||||
|
{
|
||||||
|
|
||||||
velocity.x = Mathf.SmoothDamp(velocity.x, 0.0f, ref xVelocity, friction);
|
characterController.height /= 2;
|
||||||
velocity.z = Mathf.SmoothDamp(velocity.z, 0.0f, ref zVelocity, friction);
|
capsule.height /= 2;
|
||||||
|
transform.localScale = new Vector3(transform.localScale.x, transformHeight/2, transform.localScale.z);
|
||||||
|
diving = true;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
characterController.height = controllerHeight;
|
||||||
|
capsule.height = capsuleHeight;
|
||||||
|
transform.localScale = new Vector3(transform.localScale.x, transformHeight, transform.localScale.z);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Might want to change move direction value to make triggering this speed up effect easier/harder
|
||||||
|
if(diving && moveDirection.y > 0.75 && Input.GetButtonDown("Crouch"))
|
||||||
|
{
|
||||||
|
dive++;
|
||||||
|
if(dive == 1){
|
||||||
|
maxSpeed += 10;
|
||||||
|
}
|
||||||
|
sliding = true;
|
||||||
|
slideTime = Time.time;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,30 +205,62 @@ public class PlayerController : MonoBehaviour
|
|||||||
|
|
||||||
if (wallRunning)
|
if (wallRunning)
|
||||||
{
|
{
|
||||||
maxSpeed = maxSpeedStore*1.5f;
|
|
||||||
|
if(maxSpeed < maxSpeedStore*1.5f)
|
||||||
|
{
|
||||||
|
maxSpeed += acceleration;
|
||||||
|
}
|
||||||
|
|
||||||
jump = 0;
|
jump = 0;
|
||||||
|
|
||||||
if(wall == 1)
|
if(wall == 1)
|
||||||
{
|
{
|
||||||
startTime = Time.time;
|
wallRunTime = Time.time;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(startTime + oneSec < Time.time)
|
if(wallRunTime + oneSec < Time.time)
|
||||||
{
|
{
|
||||||
|
|
||||||
moveDirection.y += Physics.gravity.y * (gravity/8) * Time.deltaTime;
|
moveDirection.y += Physics.gravity.y * (gravity/8) * Time.deltaTime;
|
||||||
//wallRunning = false;
|
|
||||||
maxSpeed = maxSpeedStore;
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
moveDirection.y = 0.0f;
|
moveDirection.y = 0.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
velocity.x += moveDirection.x;
|
||||||
|
velocity.z += moveDirection.z;
|
||||||
|
|
||||||
|
if((Input.GetAxis("Horizontal") == 0 && Input.GetAxis("Vertical") == 0) || Input.GetButton("Stop")){
|
||||||
|
|
||||||
|
//Remove or "lower" friction to add an 'ice' effect
|
||||||
|
velocity.x = Mathf.SmoothDamp(velocity.x, 0.0f, ref xVelocity, friction);
|
||||||
|
velocity.z = Mathf.SmoothDamp(velocity.z, 0.0f, ref zVelocity, friction);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(maxSpeed > maxSpeedCap)
|
||||||
|
{
|
||||||
|
maxSpeed = maxSpeedCap;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(characterController.velocity == new Vector3(0, 0, 0))
|
||||||
|
{
|
||||||
|
maxSpeed = maxSpeedStore;
|
||||||
|
}
|
||||||
|
|
||||||
velocity = Vector3.ClampMagnitude(velocity, maxSpeed);
|
velocity = Vector3.ClampMagnitude(velocity, maxSpeed);
|
||||||
|
|
||||||
velocity.y = moveDirection.y;
|
velocity.y = moveDirection.y;
|
||||||
|
|
||||||
|
Debug.Log(moveDirection.y+"\n");
|
||||||
|
|
||||||
|
if(moveDirection.y <= -5 && Mathf.Abs(velocity.x) <= 1.5f && Mathf.Abs(velocity.z) <= 1.5f)
|
||||||
|
{
|
||||||
|
velocity.x = velocity.x * Mathf.Abs(moveDirection.y);
|
||||||
|
velocity.z = velocity.z * Mathf.Abs(moveDirection.y);
|
||||||
|
}
|
||||||
|
|
||||||
// Move the controller
|
// Move the controller
|
||||||
characterController.Move(velocity * Time.deltaTime);
|
characterController.Move(velocity * Time.deltaTime);
|
||||||
|
|
||||||
|
|||||||
@@ -8,4 +8,6 @@ EditorBuildSettings:
|
|||||||
- enabled: 1
|
- enabled: 1
|
||||||
path: Assets/Scenes/Test Scene.unity
|
path: Assets/Scenes/Test Scene.unity
|
||||||
guid: 9fc0d4010bbf28b4594072e72b8655ab
|
guid: 9fc0d4010bbf28b4594072e72b8655ab
|
||||||
m_configObjects: {}
|
m_configObjects:
|
||||||
|
com.unity.input.settings: {fileID: 11400000, guid: 5dbe934aa009ccc4591ccf96f49a3d48,
|
||||||
|
type: 2}
|
||||||
|
|||||||
@@ -38,13 +38,13 @@ InputManager:
|
|||||||
axis: 0
|
axis: 0
|
||||||
joyNum: 0
|
joyNum: 0
|
||||||
- serializedVersion: 3
|
- serializedVersion: 3
|
||||||
m_Name: Fire1
|
m_Name: Crouch
|
||||||
descriptiveName:
|
descriptiveName:
|
||||||
descriptiveNegativeName:
|
descriptiveNegativeName:
|
||||||
negativeButton:
|
negativeButton:
|
||||||
positiveButton: left ctrl
|
positiveButton: left ctrl
|
||||||
altNegativeButton:
|
altNegativeButton:
|
||||||
altPositiveButton: mouse 0
|
altPositiveButton:
|
||||||
gravity: 1000
|
gravity: 1000
|
||||||
dead: 0.001
|
dead: 0.001
|
||||||
sensitivity: 1000
|
sensitivity: 1000
|
||||||
@@ -54,29 +54,29 @@ InputManager:
|
|||||||
axis: 0
|
axis: 0
|
||||||
joyNum: 0
|
joyNum: 0
|
||||||
- serializedVersion: 3
|
- serializedVersion: 3
|
||||||
m_Name: Fire2
|
m_Name: Walk
|
||||||
descriptiveName:
|
|
||||||
descriptiveNegativeName:
|
|
||||||
negativeButton:
|
|
||||||
positiveButton: left alt
|
|
||||||
altNegativeButton:
|
|
||||||
altPositiveButton: mouse 1
|
|
||||||
gravity: 1000
|
|
||||||
dead: 0.001
|
|
||||||
sensitivity: 1000
|
|
||||||
snap: 0
|
|
||||||
invert: 0
|
|
||||||
type: 0
|
|
||||||
axis: 0
|
|
||||||
joyNum: 0
|
|
||||||
- serializedVersion: 3
|
|
||||||
m_Name: Fire3
|
|
||||||
descriptiveName:
|
descriptiveName:
|
||||||
descriptiveNegativeName:
|
descriptiveNegativeName:
|
||||||
negativeButton:
|
negativeButton:
|
||||||
positiveButton: left shift
|
positiveButton: left shift
|
||||||
altNegativeButton:
|
altNegativeButton:
|
||||||
altPositiveButton: mouse 2
|
altPositiveButton:
|
||||||
|
gravity: 1000
|
||||||
|
dead: 0.001
|
||||||
|
sensitivity: 1000
|
||||||
|
snap: 0
|
||||||
|
invert: 0
|
||||||
|
type: 0
|
||||||
|
axis: 0
|
||||||
|
joyNum: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
m_Name: Stop
|
||||||
|
descriptiveName:
|
||||||
|
descriptiveNegativeName:
|
||||||
|
negativeButton:
|
||||||
|
positiveButton: mouse 1
|
||||||
|
altNegativeButton:
|
||||||
|
altPositiveButton:
|
||||||
gravity: 1000
|
gravity: 1000
|
||||||
dead: 0.001
|
dead: 0.001
|
||||||
sensitivity: 1000
|
sensitivity: 1000
|
||||||
@@ -182,11 +182,11 @@ InputManager:
|
|||||||
axis: 1
|
axis: 1
|
||||||
joyNum: 0
|
joyNum: 0
|
||||||
- serializedVersion: 3
|
- serializedVersion: 3
|
||||||
m_Name: Fire1
|
m_Name: Crouch
|
||||||
descriptiveName:
|
descriptiveName:
|
||||||
descriptiveNegativeName:
|
descriptiveNegativeName:
|
||||||
negativeButton:
|
negativeButton:
|
||||||
positiveButton: joystick button 0
|
positiveButton: joystick button 7
|
||||||
altNegativeButton:
|
altNegativeButton:
|
||||||
altPositiveButton:
|
altPositiveButton:
|
||||||
gravity: 1000
|
gravity: 1000
|
||||||
@@ -198,23 +198,7 @@ InputManager:
|
|||||||
axis: 0
|
axis: 0
|
||||||
joyNum: 0
|
joyNum: 0
|
||||||
- serializedVersion: 3
|
- serializedVersion: 3
|
||||||
m_Name: Fire2
|
m_Name: Walk
|
||||||
descriptiveName:
|
|
||||||
descriptiveNegativeName:
|
|
||||||
negativeButton:
|
|
||||||
positiveButton: joystick button 1
|
|
||||||
altNegativeButton:
|
|
||||||
altPositiveButton:
|
|
||||||
gravity: 1000
|
|
||||||
dead: 0.001
|
|
||||||
sensitivity: 1000
|
|
||||||
snap: 0
|
|
||||||
invert: 0
|
|
||||||
type: 0
|
|
||||||
axis: 0
|
|
||||||
joyNum: 0
|
|
||||||
- serializedVersion: 3
|
|
||||||
m_Name: Fire3
|
|
||||||
descriptiveName:
|
descriptiveName:
|
||||||
descriptiveNegativeName:
|
descriptiveNegativeName:
|
||||||
negativeButton:
|
negativeButton:
|
||||||
@@ -230,11 +214,11 @@ InputManager:
|
|||||||
axis: 0
|
axis: 0
|
||||||
joyNum: 0
|
joyNum: 0
|
||||||
- serializedVersion: 3
|
- serializedVersion: 3
|
||||||
m_Name: Jump
|
m_Name: Stop
|
||||||
descriptiveName:
|
descriptiveName:
|
||||||
descriptiveNegativeName:
|
descriptiveNegativeName:
|
||||||
negativeButton:
|
negativeButton:
|
||||||
positiveButton: joystick button 3
|
positiveButton: joystick button 6
|
||||||
altNegativeButton:
|
altNegativeButton:
|
||||||
altPositiveButton:
|
altPositiveButton:
|
||||||
gravity: 1000
|
gravity: 1000
|
||||||
@@ -246,13 +230,13 @@ InputManager:
|
|||||||
axis: 0
|
axis: 0
|
||||||
joyNum: 0
|
joyNum: 0
|
||||||
- serializedVersion: 3
|
- serializedVersion: 3
|
||||||
m_Name: Submit
|
m_Name: Jump
|
||||||
descriptiveName:
|
descriptiveName:
|
||||||
descriptiveNegativeName:
|
descriptiveNegativeName:
|
||||||
negativeButton:
|
negativeButton:
|
||||||
positiveButton: return
|
positiveButton: joystick button 1
|
||||||
altNegativeButton:
|
altNegativeButton:
|
||||||
altPositiveButton: joystick button 0
|
altPositiveButton:
|
||||||
gravity: 1000
|
gravity: 1000
|
||||||
dead: 0.001
|
dead: 0.001
|
||||||
sensitivity: 1000
|
sensitivity: 1000
|
||||||
@@ -262,29 +246,61 @@ InputManager:
|
|||||||
axis: 0
|
axis: 0
|
||||||
joyNum: 0
|
joyNum: 0
|
||||||
- serializedVersion: 3
|
- serializedVersion: 3
|
||||||
m_Name: Submit
|
m_Name: Mouse X
|
||||||
descriptiveName:
|
descriptiveName:
|
||||||
descriptiveNegativeName:
|
descriptiveNegativeName:
|
||||||
negativeButton:
|
negativeButton:
|
||||||
positiveButton: enter
|
positiveButton:
|
||||||
altNegativeButton:
|
altNegativeButton:
|
||||||
altPositiveButton: space
|
altPositiveButton:
|
||||||
gravity: 1000
|
gravity: 1000
|
||||||
dead: 0.001
|
dead: 0.25
|
||||||
sensitivity: 1000
|
sensitivity: 0.1
|
||||||
snap: 0
|
snap: 0
|
||||||
invert: 0
|
invert: 0
|
||||||
type: 0
|
type: 2
|
||||||
axis: 0
|
axis: 2
|
||||||
joyNum: 0
|
joyNum: 0
|
||||||
- serializedVersion: 3
|
- serializedVersion: 3
|
||||||
m_Name: Cancel
|
m_Name: Mouse Y
|
||||||
|
descriptiveName:
|
||||||
|
descriptiveNegativeName:
|
||||||
|
negativeButton:
|
||||||
|
positiveButton:
|
||||||
|
altNegativeButton:
|
||||||
|
altPositiveButton:
|
||||||
|
gravity: 1000
|
||||||
|
dead: 0.25
|
||||||
|
sensitivity: 0.1
|
||||||
|
snap: 0
|
||||||
|
invert: 1
|
||||||
|
type: 2
|
||||||
|
axis: 3
|
||||||
|
joyNum: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
m_Name: Pause
|
||||||
descriptiveName:
|
descriptiveName:
|
||||||
descriptiveNegativeName:
|
descriptiveNegativeName:
|
||||||
negativeButton:
|
negativeButton:
|
||||||
positiveButton: escape
|
positiveButton: escape
|
||||||
altNegativeButton:
|
altNegativeButton:
|
||||||
altPositiveButton: joystick button 1
|
altPositiveButton:
|
||||||
|
gravity: 1000
|
||||||
|
dead: 0.001
|
||||||
|
sensitivity: 1000
|
||||||
|
snap: 0
|
||||||
|
invert: 0
|
||||||
|
type: 0
|
||||||
|
axis: 0
|
||||||
|
joyNum: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
m_Name: Pause
|
||||||
|
descriptiveName:
|
||||||
|
descriptiveNegativeName:
|
||||||
|
negativeButton:
|
||||||
|
positiveButton: joystick button 9
|
||||||
|
altNegativeButton:
|
||||||
|
altPositiveButton:
|
||||||
gravity: 1000
|
gravity: 1000
|
||||||
dead: 0.001
|
dead: 0.001
|
||||||
sensitivity: 1000
|
sensitivity: 1000
|
||||||
|
|||||||
Reference in New Issue
Block a user