Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4c04f3d802 | ||
|
|
a0d01964c7 | ||
|
|
b696d526d5 | ||
|
|
b6ad41aa53 | ||
|
|
d50f3f315e | ||
|
|
8c48b3bdbb | ||
|
|
71667543b7 | ||
|
|
e104e71bba |
@@ -147,8 +147,8 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 150911451}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0.5, z: 0.5}
|
||||
m_LocalScale: {x: 0.5, y: 0.5, z: 0.5}
|
||||
m_LocalPosition: {x: 0, y: 0.5, z: 0}
|
||||
m_LocalScale: {x: 0.25, y: 0.5, z: 1.5}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 741217456}
|
||||
m_RootOrder: 0
|
||||
@@ -538,6 +538,9 @@ MonoBehaviour:
|
||||
speed: 20
|
||||
jumpSpeed: 20
|
||||
gravity: 5
|
||||
rotationSpeed: 20
|
||||
pivot: {fileID: 1402695046}
|
||||
playerModel: {fileID: 150911451}
|
||||
--- !u!143 &741217458
|
||||
CharacterController:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -11,10 +11,12 @@ public class PlayerController : MonoBehaviour
|
||||
{
|
||||
CharacterController characterController;
|
||||
|
||||
public float speed = 20.0f;
|
||||
public float jumpSpeed = 15.0f;
|
||||
public float gravity = 5.0f;
|
||||
public float rotationSpeed = 150.0f;
|
||||
public float speed;
|
||||
public float jumpSpeed;
|
||||
public float gravity;
|
||||
public float rotationSpeed;
|
||||
public Transform pivot;
|
||||
public GameObject playerModel;
|
||||
|
||||
private bool extraJump = true;
|
||||
private Vector3 moveDirection;
|
||||
@@ -28,10 +30,8 @@ public class PlayerController : MonoBehaviour
|
||||
{
|
||||
|
||||
float yStore = moveDirection.y;
|
||||
moveDirection = (transform.forward * Input.GetAxisRaw("Vertical")) + (transform.right * Input.GetAxisRaw("Horizontal"));
|
||||
|
||||
//Player rotation
|
||||
transform.Rotate(0, Input.GetAxis("Horizontal") * Time.deltaTime * rotationSpeed, 0);
|
||||
//Need to switch to 'raw' when using keyboard
|
||||
moveDirection = (transform.forward * Input.GetAxis("Vertical")) + (transform.right * Input.GetAxis("Horizontal"));
|
||||
|
||||
if (extraJump == true)
|
||||
{
|
||||
@@ -73,5 +73,15 @@ public class PlayerController : MonoBehaviour
|
||||
|
||||
// Move the controller
|
||||
characterController.Move(moveDirection * Time.deltaTime);
|
||||
|
||||
//Move the player in different directions based on camera look direction
|
||||
//Need to switch to 'raw' when using keyboard
|
||||
if(Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0)
|
||||
{
|
||||
transform.rotation = Quaternion.Euler(0f, pivot.rotation.eulerAngles.y, 0f);
|
||||
Quaternion newRotation = Quaternion.LookRotation(new Vector3(moveDirection.x, 0f, moveDirection.z));
|
||||
playerModel.transform.rotation = Quaternion.Slerp(playerModel.transform.rotation, newRotation, rotationSpeed * Time.deltaTime);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
m_EditorVersion: 2019.2.8f1
|
||||
m_EditorVersionWithRevision: 2019.2.8f1 (ff5b465c8d13)
|
||||
m_EditorVersion: 2019.2.11f1
|
||||
m_EditorVersionWithRevision: 2019.2.11f1 (5f859a4cfee5)
|
||||
|
||||
Reference in New Issue
Block a user