Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
Futuristichub's avatar
Futuristichub
Honored Guest
11 years ago

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!

5 Replies

Replies have been turned off for this discussion
  • Anonymous's avatar
    Anonymous
    Try transform.forward instead of Vector3.forward. Vector3.forward is a global direction, transform.forward is the localized direction.
  • "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. :/
  • "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;
  • 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;
  • "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!!