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