Search Unity

Question Flying Disc Gyroscopic Stability (VR)

Discussion in 'Physics' started by SubjectDeltaV, Jun 8, 2022.

  1. SubjectDeltaV

    SubjectDeltaV

    Joined:
    May 9, 2022
    Posts:
    2
    I did some searching but found nothing that could be relevant to this specific case (which doesn't mean its not out there, but its not easy to find if it is). New to Unity (and game dev to a certain extent, explain it to me like I'm a toddler, as Necessary) I am making a weapon for my VR game that behaves partly like a Boomerang and Partly like a Frisbee.

    I managed to approximate physics creating lift (still need to figure out banking inducing turns, but one problem at a time.) The current issue is that it's very wobbly in flight. Most frisbees will stabilize relative to the rotational speed, courtesy of gyroscopic physics. But since the script only approximates that it's obviously not stabilizing. Is there an easy way to even out or dampen the wobbly nature of its flight path? Code for the attached class follows; Relevant Game Object also has SteamVRs Throwable & Interactable Classes, as well as the obvious Collider and RigidBody.

    Code (CSharp):
    1. public class Disc : Weapon
    2. {
    3.     private Interactable interact;
    4.     private Throwable throwable;
    5.     private Rigidbody rigid;
    6.     public float liftCoefficient;
    7.     [Tooltip("The threshold where the object can generate lift or not, object must ALSO NOT be in players hand.")]
    8.     public float liftVelocityThreshold;
    9.     // Start is called before the first frame update
    10.     void Start()
    11.     {
    12.         interact = gameObject.GetComponent<Interactable>();
    13.         rigid = gameObject.GetComponent<Rigidbody>();
    14.         throwable = gameObject.GetComponent<Throwable>();
    15.     }
    16.  
    17.     // Update is called once per frame
    18.     void FixedUpdate()
    19.     {
    20.         if(interact.attachedToHand == false && rigid.velocity.magnitude > liftVelocityThreshold) //check if current velocity is high enough and object is NOT in players hand
    21.         {
    22.             Debug.Log("Object Moving at Sufficient Speed to Generate Lift");
    23.             Vector3 LiftForce;
    24.             //Apply An Upward Force dependent on spin speed to simulate lift
    25.             float V = rigid.angularVelocity.magnitude; //obtain rotational speed
    26.             float L; //where L is lift
    27.             float c = liftCoefficient;
    28.             //density is not included
    29.             //for simplicity, area is not included
    30.             L = 0.5f * V * c;
    31.             Debug.Log("Applied Lift Force To Object Equivilant to " + L + " Newtons");
    32.             LiftForce = new Vector3(0, L, 0); //put Lift into a Vector 3
    33.             rigid.AddRelativeForce(LiftForce); //add the Lift Force
    34.         }
    35.     }
    36. }
    37.  
    As an added side note, if anyone knows how to get it to turn when it banks it would be helpful, I suspect it's an issue with how I'm applying the force (or perhaps I need to dial up the coefficient of lift to compensate for the lack of Area or Density not being in the equation), but I'll fix it later.
     
  2. ViggeBoi

    ViggeBoi

    Joined:
    Jun 20, 2019
    Posts:
    6
    Did you find out how to stop the wobbling?
     
  3. SubjectDeltaV

    SubjectDeltaV

    Joined:
    May 9, 2022
    Posts:
    2
    As it turns out turning the lift coefficient up solved the problem quite handily.