Question by
AUSLER · Jun 09, 2017 at 05:59 PM ·
scripting problemjumpingnewbiefalling
player falls slowly
hi, I am very new to coding and i'm making a 3D top down game my player moves and jumps pretty nicely and smoothly but falls down slower than an astronaut in space backwards
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class PlayerController : MonoBehaviour {
public float movementSpeed = 30.0f;
private float Vector3;
public float jumpSpeed = 10f;
public float gravity = 9.8f;
void Start () {
Cursor.visible = false;
}
// Update is called once per frame
void Update ()
{
//walking
var x = Input.GetAxis ("Horizontal") * Time.deltaTime * movementSpeed;
var z = Input.GetAxis ("Vertical") * Time.deltaTime * movementSpeed;
transform.Translate (0, 0, z);
transform.Translate (x, 0, 0);
//jump
var y = Input.GetAxis ("Vertical") * Time.deltaTime * movementSpeed;
transform.Translate (0, y, 0);
}
}
i have tried dabbling around with the jump script but keep getting errors i also tried saying that if the space button is pressed the player jumps, then the code waits and after 2 seconds (when the player is it's highest) gravity is subtracted from the height
Comment