Hello, i wanna do something like Flappybird,just with an Airplane.When i keep pressing its keep going up,everything fine, but its going up with “steps” just like it would go up an stair.How can i make,that its going up smooth?And how can i make an white line behind the players way?Just like an path wich the players flew.My idea is the game “Sky glider”
using UnityEngine;
using System.Collections;
public class Playermovement : MonoBehaviour {
Vector3 velocity = Vector3.zero;
public Vector3 gravity;
public Vector3 flapVelocity;
public float maxSpeed = 5f;
public float fixedvelocity = 1f;
bool didFlap = false;
// Use this for initialization
void Start () {
}
void Update() {
if (Input.GetKey(KeyCode.Space) || Input.GetMouseButton(0) ) {
didFlap = true;
}
}
// Update is called once per frame
void FixedUpdate () {
velocity.x = fixedvelocity;
velocity += gravity * Time.deltaTime;
if (didFlap == true) {
didFlap = false;
if(velocity.y <0)
velocity += flapVelocity;
}
velocity = Vector3.ClampMagnitude (velocity, maxSpeed);
transform.position += velocity * Time.deltaTime;
}