void Start()
 {
     if (Camera == null)
     {
         Camera = Camera.main;
     }
     body = GetComponent <CustomRigidBody>();
 }
    public void DropFly()
    {
        //Fly will start dropping when notified
        CustomRigidBody rb = this.GetComponent <CustomRigidBody> ();

        rb.useGravity     = true;
        rb.useWind        = false;
        rb.bounceOnImpact = true;
    }
    public void OnCollide(SCollisionInfo collInfo)
    {
        CustomRigidBody rb = collInfo.otherObj.GetComponent <CustomRigidBody> ();

        if (rb != null)
        {
            rb.SetWindVelocity(m_currentWind);
        }
    }
Пример #4
0
    // Projectile force is non verlet due to the fact, we are not acting acceleration to it, we want a steady speed. We will cause initial speed at first,
    // and let newtons 2nd law act for a steady speed with no acceleration aka no wind resistance
    public void Euler()
    {
        CustomRigidBody P              = this;
        float           Vx             = P.angVelocity.x;
        float           Vz             = P.angVelocity.z;
        float           Vy             = P.angVelocity.y; // slows down the velocity, but the gravity is still not actiing on it
        Vector3         newAngVelocity = new Vector3(Vx, Vy, Vz);


        // distance = change in velocity * change in time, the distance is being travelled in linearly without any hinderance
        P.position           = P.position + P.angVelocity * Time.deltaTime; // assuming a constant velocity and no wind resistance
        P.transform.position = (P.position);                                // use delta time for the gravity effect
    }
    // Add reaction the the turkey on the ball. increase the newforcey to see better results
    public void addballforce(CustomRigidBody c)
    {
        float newforcex = c.forcex;
        float newforcey = c.forcey;

        newforcex = newforcex * 5f; // lower the x
        newforcey = newforcey * 5f;;

        float f = (c.oldposition.y / (c.transform.position.y + c.oldposition.y));

        // if falling from above
        // if (c.transform.position.y - c.oldposition.y <=0)
        // {
        //applyforce(new Vector3(-newforcex, -newforcey, 0));
        //   }


        // if (c.transform.position.y - c.oldposition.y > 0)
        // {

        acc = new Vector3(acc.x, 0, 0);
        applyforce(new Vector3(-newforcex, -newforcey, 0));
        // }
    }
Пример #6
0
 // Use this for initialization
 void Start()
 {
     frisbee       = GameObject.Find("RecordingFrisbee");
     frisbeeScript = frisbee.GetComponent <CustomRigidBody> ();
     firstThrow    = true;
 }