cancel
Showing results for 
Search instead for 
Did you mean: 

Harrier Jet Scripting Problem

Futuristichub
Honored Guest
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 5

Anonymous
Not applicable
Try transform.forward instead of Vector3.forward. Vector3.forward is a global direction, transform.forward is the localized direction.

Futuristichub
Honored Guest
"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
Honored Guest
"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;

cybereality
Grand Champion
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;

Futuristichub
Honored Guest
"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!!