Var localVelocity = transform.InverseTransformDirection(rb.velocity) Solution: Move rb.velocity to local-space and solve for AoA with trigonometry. AoA must work in both positive and negative directions otherwise negative pitch and inverted flight would not be possible. Vector3.Angle will return an unsigned angle.AoA is the angle between the local chord-line of your wing and the aircraft's velocity. Vector3.forward and rb.velocity are both in world-space.Issue: angleOfAttack = Vector3.Angle(Vector3.forward, rb.velocity) So there are a number of issues with your code. Rb.AddForce(transform.forward * EnginePower) Īnd for Drag coefficient: I used data from wiki too (0.021f). Rb.drag = coefficientDrag * 0.5f * Mathf.Pow(rb.velocity.magnitude,2) * 1.2754f * 78.04f private void calculateEnginePower()ĮnginePower = engineThrust * ThrottleInput ĪngleOfAttack = Vector3.Angle(Vector3.forward, rb.velocity) ĪngleOfAttack = Mathf.Clamp(angleOfAttack, 0, 90) Ĭoefficient = Mathf.Pow(1225.04f * rb.velocity.magnitude, 2) - 1 //M^2-2 where: M is mach.ĬoefficientLift = (4 * angleOfAttack) / Mathf.Sqrt(coefficient) To my game object, I gave the rigidbody component mass = 19670 kg.Įngine thrust = 2 * 116000.0f Newton. I tried to use real data and get it from wiki(F22 Raptor). and make a simple script in unity, but if I start, my plane cant move or if I change drag to zero, it cant lift. I watch some video from airplane physics. I want to make a simple aircraft controller, what looks like little realistic in unity.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |