Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea: 2D Aircraft Physics #3

Closed
RangerOri opened this issue Jan 11, 2021 · 6 comments
Closed

Idea: 2D Aircraft Physics #3

RangerOri opened this issue Jan 11, 2021 · 6 comments

Comments

@RangerOri
Copy link

Hey,

Wow! This is an absolutely stunning library, well detailed, well defined and I was exetremely impressed with the amount of information spilled into it.

I don't have an issue, but I do have an idea. (I don't know how create a discussion or anything so I went here to issues)
screenshots

I want to create a very simple aircraft physics, but in 2D, so I thought about connecting and using parts of the scripts for it.
However, I don't know how to perform a reduction on your library for it, I can try, but it will take me a lot of time.
I would like to know if you could minimize it for it? or at least guide me towards my vision?

I thought about only connecting the AeroSurface for the tail and ailerons, and removing yaw and roll (I could animate the roll easily I believe), so basically all I need is pitch movement. And I'm still clueless for the 2D aerodynamics for the plane.
What do I do with the scripts so I won't get any sudden movement on an axis that shouldn't move?
Of course, assuming the plane direction is Z and Y, The plane shouldn't change it position in X in 2D world.

Thanks,
Ori

@gasgiant
Copy link
Owner

gasgiant commented Jan 13, 2021

Hi,

I'm not sure that this system is a great fit for your game. Since it's a 2D game I assume it leans much more into the "arcade" than into "simulation". And it is then unclear if your game would benefit from the realistic simulation of aerodynamics or such simulation will actually make it less enjoyable. I think you would be better with your custom controller.

However if you really want to try this project in 2D I think the simplest option is to restrict translational X axis and rotational Y and Z axes on the rigidbody (it has checkboxes for it in the inspector). Then the plane will move only in Z and Y axes and rotate only around X.

@RangerOri
Copy link
Author

Hey,

So I've done it, and it does restrict the axis.
However, I'm facing an issue related to Unity's engine itself. I am in 2D mode, your code runs on the transform.forward vector.
In 2D project, the forward is actually translated to transform.right. This gives unpredictable movement and bugs.

@gasgiant
Copy link
Owner

So, I tried restricting rotation axis and it kind of worked. Resctriction of rotational axis broke the velocity predictor, so you'll have to disable it for this thing to behave correctly. Also note, that rotational axis restrictions are relative to the rigidbody, while position restrictions are global. Even with all that done wings seem to always stall.

I would investigate further but I really think it's not a good idea to use this plane physics system in a 2D game. You are not getting anything good from it and only make the development needlessly harder.

@RangerOri
Copy link
Author

I did look for information online for creating 2D arcade-y like physics games, I just couldn't find anything that behaves good.
It's quite funny, because it seems to be it should be really simple.

I'll try investigating your code, cause it does behave nicely on 2D movement, maybe I just need to adjust some of the axis movement, thanks for everything up until now anyway, you are a genius, and you rock!

@gasgiant
Copy link
Owner

gasgiant commented Mar 22, 2021

Some quick ideas for how to make a thing that will better suit your game. Since the game is 2D I assume it's an arcady one.

  1. You can simply move a gameobject in the direction where it looks. Rotate the object to change direction. Add some speed changes so it feels better (maybe increase it when going down and decrease while going up). You can play with such type of a controller a lot and get an awesom result.
  2. You can use rigidbody for a simple physics based controller. Not real plane physics, just some physics. Add some serious linear drag to a rigidbody and apply force in the direction where it looks. Apply torque to turn. The example plane here works like this: https://github.com/brihernandez/MouseFlight. The actual autopilot stuff is cool, but is not relevant for you. But the example plane physics is stupid simple and easily adaptable for 2D.
  3. Make a simplified 2D verison of this project. You can treat the plane like a singular aerodynamic surface and make lift and drag coefficients functions with, say, AnimatedCurve editor by hand (using realistic ones for reference). And again apply torque directly to control the thing, without bothering with control surfaces.

@RangerOri
Copy link
Author

I attempted (1) for a couple of times, no matter how much I play with the rotation, I need to add aerodynamics into it so it would be realistic enough, otherwise it looks like a space/sci-fi shooter.
I did find that project (2) I think a year ago, I'll look into it again, maybe with restricting axes as you suggested.

If I wouldn't succeed with the above, I'll attempt to go in further with your project.
I still believe you created the best scripts so far. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants