brihernandez / ArcadeJetFlightExample

Example project featuring simple arcade flight.
MIT License
54 stars 15 forks source link

Add zero throttle + stalling+ landing #2

Open ghost opened 5 years ago

ghost commented 5 years ago

How do I add l the ability for zero throttles? Next, how do I add a feature so that the plane stalls when the speed drops too low? Finally, how do I add a feature so that the plane can land only when touching certain objects(runway, but explode when it hits anywhere else), plus the plane can only be so tilted to the side?

brihernandez commented 4 years ago

How do I add l the ability for zero throttles?

In StickInput you would want to handle for some input and then set the target to zero so that the throttle moves to zero.

Next, how do I add a feature so that the plane stalls when the speed drops too low?

That's out of the scope of something like this, but I guess you might make the plane rotate downwards if the speed is too low. That's not really how it works, but that's how arcade games work. Honestly the style of physics doesn't in this project don't work too well if you need to actually land the plane, or fly the plane at very low speeds. It works best when you keep the plane at flying speeds the same way the Ace Combat games never let you slow down too much outside of very special circumstances.

the plane can land only when touching certain objects(runway, but explode when it hits anywhere else)

You'd probably want to use layers for that. If you detect a collision with OnCollisionEnter and the other thing has a collider on a "Runway" layer that you made, then nothing happens. If not, then it explodes.

plus the plane can only be so tilted to the side?

Simplest way would be in above collision check to check euler angles using transform.eulerAngles are within some limit. Personally though I would prefer to use one of the direction vectors. For example check transform.right.y to see if it's close to zero. If that value is 1, then the plane is banked 90 degrees to the left. If it's -1, the plane is banked 90 degrees to the right. If it's zero, that means wings are level.