fixed
This commit is contained in:
@@ -43,19 +43,15 @@ public class Player : MonoBehaviour
|
||||
Velocity = new Vector2(forwardSpeed,0);
|
||||
|
||||
CameraFollower.Target= body;
|
||||
CameraFollower.UpdateFrame();
|
||||
|
||||
playerRigidbody.bodyType = RigidbodyType2D.Static;
|
||||
playerRigidbody.gravityScale = 0;
|
||||
}
|
||||
|
||||
int lastX = 0;
|
||||
void FixedUpdate()
|
||||
{
|
||||
if (!gameStarted && Input.GetKey(KeyCode.Space))
|
||||
{
|
||||
gameStarted = true;
|
||||
playerRigidbody.bodyType = RigidbodyType2D.Dynamic;
|
||||
playerRigidbody.gravityScale = gravity;
|
||||
}
|
||||
|
||||
|
||||
if (!gameStarted)
|
||||
{
|
||||
@@ -70,6 +66,11 @@ public class Player : MonoBehaviour
|
||||
}
|
||||
HandleJump();
|
||||
|
||||
if(lastX != (int)body.position.x){
|
||||
lastX = (int)body.position.x;
|
||||
LevelGenerator.instance.GenerateAhead(2);
|
||||
}
|
||||
|
||||
//Gravity
|
||||
Velocity -= new Vector2(0, gravity);
|
||||
|
||||
@@ -99,6 +100,12 @@ public class Player : MonoBehaviour
|
||||
|
||||
|
||||
public void Jump(){
|
||||
if (!gameStarted)
|
||||
{
|
||||
gameStarted = true;
|
||||
playerRigidbody.bodyType = RigidbodyType2D.Dynamic;
|
||||
playerRigidbody.gravityScale = gravity;
|
||||
}
|
||||
if(!isReadyToJump){ return; }
|
||||
jumpTimer =0;
|
||||
Velocity = new Vector2(Velocity.x, jumpForce);
|
||||
|
||||
Reference in New Issue
Block a user