SimpleWings
SimpleWings copied to clipboard
Wind
Hi, I have been trying now for a while to add "wind" to this and failed miserably.
I was wondering if this is something you could do easily?
Ideally I want to set a wind vector (direction & speed) and it effect the plane or individual airfoils. (relative velocity and the wind force)
Thanks
Hi, I have been trying now for a while to add "wind" to this and failed miserably.
I was wondering if this is something you could do easily?
Ideally I want to set a wind vector (direction & speed) and it effect the plane or individual airfoils. (relative velocity and the wind force)
Thanks
I believe you can easily add external wind effects by adding a vector3 to the local velocity. Try modifying SimpleWing.cs line 37 like that?
Hi, I have been trying now for a while to add "wind" to this and failed miserably. I was wondering if this is something you could do easily? Ideally I want to set a wind vector (direction & speed) and it effect the plane or individual airfoils. (relative velocity and the wind force) Thanks
I believe you can easily add external wind effects by adding a vector3 to the local velocity. Try modifying SimpleWing.cs line 37 like that?
Hi, thanks for your help, however i'm not so sure its that simple. Line 37 is used only for getting the AOA for display purposes (correct me if im wrong?)
Hi, I have been trying now for a while to add "wind" to this and failed miserably. I was wondering if this is something you could do easily? Ideally I want to set a wind vector (direction & speed) and it effect the plane or individual airfoils. (relative velocity and the wind force) Thanks
I believe you can easily add external wind effects by adding a vector3 to the local velocity. Try modifying SimpleWing.cs line 37 like that?
Hi, thanks for your help, however i'm not so sure its that simple. Line 37 is used only for getting the AOA for display purposes (correct me if im wrong?)
Right, my bad. I wanted to write line 104, in fixedUpdate. It works the same.
Hello! Wind is an implementation specific thing, so I didn't include it in this project, but here's how I add wind in my game.
Replace these lines in FixedUpdate
:
Vector3 localVelocity = transform.InverseTransformDirection(rigid.GetPointVelocity(transform.position));
localVelocity.x = 0f;
With something like this:
// Velocity that this wing feels is the velocity at its specific position,
// and any wind that might be coming from outside.
Vector3 worldVelocity = rigid.GetPointVelocity(transform.position);
worldVelocity += -environment.WindVector;
Vector3 localVelocity = transform.InverseTransformDirection(worldVelocity);
localVelocity.x = 0.0f;
In my implementation, environment
is a GameObject in the world which controls things like wind and time of day. The WindVector
on it is the direction that the wind is blowing. Wind for wings is weird, because from the wing's perspective it can't tell the difference between wind and just moving through the air normally, so by adding the wind's velocity to the velocity the wing already has, you're simulating that effect per-wing, which is going to be more accurate than applying a velocity to the entire plane.
Hi, thank you. I am literally working on my project which uses simple wings in, so great timing as I still haven't got back around to implementing wind. I had several attempts and got close, similar to what you have suggested but not exactly so looking forward to trying it.
Am i correct in saying that this will add the wind velocity to each wing which will effect its lift/drag ETC. But will this actually add the forces to the overall plane in a manner that will for instance make the aircraft crab with a side wind?
Thanks
wind velocity to each wing which will effect its lift/drag ETC
Yes. The important thing is that it affects the lift and drag accordingly, which will generate unusual forces that will naturally cause the plane to crab into the wind since that's just how the physics works out. The more realistic your arrangement of wings on the plane are, the more realistic an effect you're going to get. E.g. if you have a very large vertical tail that's offset from the center of mass, not only will the plane try to weather vane into the wind, but it'll also induce a rolling moment because of the drag incurred.
Here's a gif of my game flying through wind. The camera is looking at the velocity vector, which is direction where the plane is actually moving.
That's great, thank you. Will have a play this afternoon. It really is a great system.
Hello! Wind is an implementation specific thing, so I didn't include it in this project, but here's how I add wind in my game.
Replace these lines in
FixedUpdate
:Vector3 localVelocity = transform.InverseTransformDirection(rigid.GetPointVelocity(transform.position)); localVelocity.x = 0f;
With something like this:
// Velocity that this wing feels is the velocity at its specific position, // and any wind that might be coming from outside. Vector3 worldVelocity = rigid.GetPointVelocity(transform.position); worldVelocity += -environment.WindVector; Vector3 localVelocity = transform.InverseTransformDirection(worldVelocity); localVelocity.x = 0.0f;
In my implementation,
environment
is a GameObject in the world which controls things like wind and time of day. TheWindVector
on it is the direction that the wind is blowing. Wind for wings is weird, because from the wing's perspective it can't tell the difference between wind and just moving through the air normally, so by adding the wind's velocity to the velocity the wing already has, you're simulating that effect per-wing, which is going to be more accurate than applying a velocity to the entire plane.
3 years later and someone found use for your comment :) Thank you for your amazing work