Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Calculate Angle Of Attack For Frisbee Physics?

Discussion in 'General Discussion' started by Hugo768, Aug 9, 2023.

  1. Hugo768

    Hugo768

    Joined:
    Feb 19, 2023
    Posts:
    1
    Hi!
    I'm currently makling a discgolf game, and getting the angle of attack of the frisbee is essential to make realistic physics.

    But I'm currently struggling to calculate the AOA. I'm using an empty gameobject which forces like lift and drag is applied to. And for AOA / nose angle I'm using another gameobject(also acting as the disc body) parented to the empty gameobject, this allows it to be rotated differently on the x-axis compared to the empty gameobject and making it possible to throw the disc with different nose angles.

    Using this code:

    aoa = Vector3.SignedAngle(axisRB.velocity, aoaVector.transform.forward, discAxis.transform.right);

    axisRB => RigidBody component attached to the empty gameobject
    aoaVector => Disc body, simply the nose angle of the frisbee
    discAxis => Empty gameobject(the one which forces like lift and drag is applied to)

    The AOA is not consistent, sometimes it varies between huge numbers like -100 and 100 in just a second which makes the disc fly away extremely fast when calculating forces based on the AOA.

    I know it might be hard to understand my description, so if clips and more code is needed I can provide that. But my question is if Unity is capable of calculating the angle between two different object at all, or if I'm making the mistake?

    Thanks in advance!
    //Hugo
     
  2. Voronoi

    Voronoi

    Joined:
    Jul 2, 2012
    Posts:
    571
    Oooh! What a cool idea to simulate frisbee physics for a game! No idea how to help, but would love to see you get this working accurately.

    Generally speaking, I don't think this is a Unity limitation, it's a math calculation to figure out the AOA. I would imagine that you should try to develop all of the physics and flight calculation on your own and not rely on physics for anything but collision detection.
     
  3. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,321
    A frisbee is a disk. At the top of the disk, you can place normal facing up which will effectively define a plane in which disk lies. Calculating angle of attack would require you to use that normal.

    Basically, we know how frisbee is tilted, and where it is going. So, you take frisbee movement vector, negate it, and you'll effectively get a vector of stream of incoming air. Then you perform dot product between that vector and "normal" at the top of frisbee, and you'll get how much the air is pushing frisbee along its normal, and in which direction. (up or down). Technically you can calculate angle of attack from that using asin/acos, but you might not even need it.
    upload_2023-8-12_10-1-6.png