ive got me a nice 2d jet flying round the place
the screen wrap works on x
on Y i have a collider at the top and my plane gets stuck there
i tried bouncy material but that wasnt suitable either
i want to reverse the plane ie turn it around and give it a little push when it hits the collider
do i just do a oncollisionenter method thing and then inside turn the plane around using transform
but how do i know what angle my plane is at and what direction its going?
1 Like
Hey again Epoch… one way for the ceiling (because it is horizontal) is to figure out that whatever angular “upness” your plane has, just rotate it forward to the same amount of “downness,” working from an angular standpoint.
OR you can just force the plane to level off horizontal (left or right), and give it a little constant 10-degrees or so of nose-down.
A more general case is to do some vector math with the Vector3.Reflect() method, but from our chat yesterday I know you are tracking your own “rotation” in the transform, and this will not work for you. To use Reflect you would have to turn the angle into a vector, do the reflect, then turn the resulting vector back into an angle, which is a bit overkill.
i like this:
Hey again Epoch… one way for the ceiling (because it is horizontal) is to figure out that whatever angular “upness” your plane has, just rotate it forward to the same amount of “downness,” working from an angular standpoint.
1 Like
Here’s a smoother way too: when you get above the ceiling position (however you determine that), set a boolean that forces a “nose over downwards” movement and inhibits the user from pulling the nose up.
Keep this state going until:
- you are below the ceiling limit
- or you are pointed massively downwards (say 45 degrees or so)
This will ensure a smooth nose-over and return to play area.
Thanks buddy
when you get above the ceiling position (however you determine that) - collider as trigger?
inhibits the user from pulling the nose up - stop movement on rotate
so like
bool tooHigh = false
then past the trigger its true
allow mouse1 && !tooHigh?
something like that?
you are below the ceiling limit - another trigger?
or you are pointed massively downwards (say 45 degrees or so) - how do i determine what angle my airplane is at?
can it be done with what i have, or will i need to create another variable and capture the angle some how.
hey i was thinking it would be cool if the plane kind of stalled a bit…so x also slowed down and it falls a second or 2 before picking up speed and then being controllable again…what you think?
that is certainly how I’ve seen other games like this work. Usually they have a vague notion of airspeed, and when you point up the airspeed decreases, when you point down it increases… when it gets below a certain threshhold they start to simulate a stall by moving you downwards in addition to forward.
This has the added benefit of:
- keeping you from going any higher
- threatening to plunge you into the ground until you nose over and gain speed.