Repair jump
This commit is contained in:
parent
217cd09194
commit
db767d7a9d
@ -11,4 +11,4 @@ PhysicMaterial:
|
|||||||
staticFriction: 1
|
staticFriction: 1
|
||||||
bounciness: 0
|
bounciness: 0
|
||||||
frictionCombine: 0
|
frictionCombine: 0
|
||||||
bounceCombine: 0
|
bounceCombine: 1
|
||||||
|
@ -219,8 +219,7 @@ MonoBehaviour:
|
|||||||
runningParticles: {fileID: 1608137079}
|
runningParticles: {fileID: 1608137079}
|
||||||
rotationX: 0
|
rotationX: 0
|
||||||
mainObject: {fileID: 3244356567786994345}
|
mainObject: {fileID: 3244356567786994345}
|
||||||
jump: {x: 0, y: 20, z: 0}
|
jump: 0
|
||||||
jumpForce: 5
|
|
||||||
isRunning: 0
|
isRunning: 0
|
||||||
--- !u!65 &1172583624
|
--- !u!65 &1172583624
|
||||||
BoxCollider:
|
BoxCollider:
|
||||||
@ -550,7 +549,7 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 3244356567913423209}
|
m_GameObject: {fileID: 3244356567913423209}
|
||||||
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.55, z: -0.68}
|
m_LocalPosition: {x: 0, y: 0.55, z: -0.805}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
|
@ -19,8 +19,7 @@ public class PlayerController : MonoBehaviour
|
|||||||
bool canMove = true;
|
bool canMove = true;
|
||||||
Rigidbody rb;
|
Rigidbody rb;
|
||||||
float moveDirectionY;
|
float moveDirectionY;
|
||||||
public Vector3 jump;
|
public bool jump = false;
|
||||||
public float jumpForce = 2.0f;
|
|
||||||
private bool isGrounded = false;
|
private bool isGrounded = false;
|
||||||
public bool isRunning = false;
|
public bool isRunning = false;
|
||||||
|
|
||||||
@ -33,7 +32,6 @@ public class PlayerController : MonoBehaviour
|
|||||||
rb = GetComponent<Rigidbody>();
|
rb = GetComponent<Rigidbody>();
|
||||||
Cursor.lockState = CursorLockMode.Locked;
|
Cursor.lockState = CursorLockMode.Locked;
|
||||||
Cursor.visible = false;
|
Cursor.visible = false;
|
||||||
jump = new Vector3(0.0f, 2.0f, 0.0f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
@ -61,13 +59,23 @@ public class PlayerController : MonoBehaviour
|
|||||||
|
|
||||||
if (Input.GetKeyDown(KeyCode.Space) && isGrounded)
|
if (Input.GetKeyDown(KeyCode.Space) && isGrounded)
|
||||||
{
|
{
|
||||||
Debug.Log("Jump");
|
jump = true;
|
||||||
rb.AddForce(transform.up * jumpSpeed * 500 * Time.deltaTime, ForceMode.Impulse);
|
|
||||||
isGrounded = false;
|
isGrounded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
rb.MovePosition(rb.position + moveDirection);
|
rb.MovePosition(rb.position + moveDirection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void FixedUpdate()
|
||||||
|
{
|
||||||
|
if (jump)
|
||||||
|
{
|
||||||
|
Debug.Log("Jump");
|
||||||
|
rb.AddForce(transform.up * jumpSpeed * 100 * Time.deltaTime, ForceMode.Impulse);
|
||||||
|
jump = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void OnCollisionExit(Collision other)
|
void OnCollisionExit(Collision other)
|
||||||
{
|
{
|
||||||
if (other.gameObject.tag == "platform")
|
if (other.gameObject.tag == "platform")
|
||||||
|
Loading…
Reference in New Issue
Block a user