Skip to main content
Up and Coming
February 13, 2015

Harrier Jet Scripting Problem

Hey everyone! I've almost got my project controls complete! I need one more thing. I can't seem to get my script to allow my vehicle in the air to thrust forward and then backwards in Zero Gravity. Think Spaceship type... So far im able to get it to do everything except the trust. A roll would be nice but I can't do Forward Thrust and I tried Vector.Forward, and that only goes along an axis that i'm not facing. I would like no matter what where ever the Vehicle is facing, if I press a key, it will go forward.

Any help is much appreciated! Wait til you see the demo I have in store for you guys!

Thank you!
    This topic has been closed for replies.

    5 replies

    February 13, 2015
    Try transform.forward instead of Vector3.forward. Vector3.forward is a global direction, transform.forward is the localized direction.
    Up and Coming
    February 14, 2015
    "ronczarnik" wrote:
    Try transform.forward instead of Vector3.forward. Vector3.forward is a global direction, transform.forward is the localized direction.


    Thanks! I actually did try this and since my vehicle is in "zero G" it doesn't work well and act like Zero G. I can turn and pitch just fine but thrust forward and back in Zero G is a no go. :/
    Up and Coming
    February 14, 2015
    "FuturisticHub" wrote:
    "ronczarnik" wrote:
    Try transform.forward instead of Vector3.forward. Vector3.forward is a global direction, transform.forward is the localized direction.


    Thanks! I actually did try this and since my vehicle is in "zero G" it doesn't work well and act like Zero G. I can turn and pitch just fine but thrust forward and back in Zero G is a no go. :/



    This code keeps me on the Z axis no matter what. The Vehicle won't go forward :/

    if(Input.GetKey(KeyCode.W)) {
    transform.forward += transform.forward * Time.deltaTime * movementSpeed;
    }
    else if(Input.GetKey(KeyCode.S)) {
    transform.forward -= transform.forward * Time.deltaTime * movementSpeed;
    Inspiring
    February 14, 2015
    You're adding a direction vector to itself, which doesn't make sense.

    You need to do something like this:

    transform.position += transform.forward * Time.deltaTime * movementSpeed;
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV
    Up and Coming
    February 14, 2015
    "cybereality" wrote:
    You're adding a direction vector to itself, which doesn't make sense.

    You need to do something like this:

    transform.position += transform.forward * Time.deltaTime * movementSpeed;


    Thank you! It does work but its a sudden forward. I tried that before and the same thing. I'm trying to get a gradutal thrust and backwards thrust with "W" and "S" key. I almost got it actually. I have Pitch, Yaw, Roll, and up and down. Now all I need is a thrust. So close!!