Search Unity

JS Gravity Not Working While Moving RB Controller

Discussion in 'Scripting' started by Deleted User, Apr 25, 2015.

  1. Deleted User

    Deleted User

    Guest

    Hi I'm Fairly New To Unity And Just Getting To the Hard Stuff
    This Has Really Stumped Me
    So I Made This Code To Move Using A Rigidbody


    if (Input.GetKey("w"))
    {
    RB.velocity = (transform.forward * speed);
    }

    This works But when I Jump

    if(Input.GetKey(KeyCode.Space)&& isfalling == false){
    RB.velocity = transform.up * jumpH;
    isfalling = true;
    }
    Im Not Effected By Gravity (if I press space and W at the same time or W while im in mid air)

    so I tried this

    //press W and move Forward
    if (Input.GetKey("W"))
    {
    RB.velocity = new Vector3(transform.forward , RB.velocity.y);

    but I get the Error
    BCE0024: The type 'UnityEngine.Vector3' does not have a visible constructor that matches the argument list '(UnityEngine.Vector3, float)'.

    its a FPS
    Thx HG
     
    Last edited by a moderator: Apr 25, 2015