Beispiel #1
0
    void FixedUpdate()
    {
        //rotate object around tornado center


        //adjust spring strength relative to tornado distance
        //float distance = Vector3.Distance(transform.position, tornadoReference.transform.position);

        //spring.spring = tornadoReference.tornadoCollider.radius - Vector3.Distance(transform.position, tornadoReference.transform.position);// + (tornadoReference.minDistance);


        /*this is bad
         * transform.RotateAround(tornadoReference.transform.position, tornadoReference.GetRotationAxis(), tornadoReference.GetTornadoStrength());*/

        //this is better
        Vector3 direction = transform.position - tornadoReference.transform.position;
        //project
        Vector3 projection = Vector3.ProjectOnPlane(direction, tornadoReference.GetRotationAxis());

        projection.Normalize();
        Vector3 normal = Quaternion.AngleAxis(130, tornadoReference.GetRotationAxis()) * projection;

        normal = Quaternion.AngleAxis(tornadoReference.lift /* - Random.Range(-5.0f, 5.0f)*/, projection) * normal;
        norm   = normal;
        rigid.AddForce(normal * tornadoReference.GetStrength(), ForceMode.Force);
    }
Beispiel #2
0
    void FixedUpdate()
    {
        Vector3 direction  = transform.position - tornadoReference.transform.position;
        Vector3 projection = Vector3.ProjectOnPlane(direction, tornadoReference.GetRotationAxis());

        projection.Normalize();
        Vector3 normal = Quaternion.AngleAxis(130, tornadoReference.GetRotationAxis()) * projection;

        normal = Quaternion.AngleAxis(tornadoReference.lift, projection) * normal;
        norm   = normal;
        rigid.AddForce(normal * tornadoReference.GetStrength(), ForceMode.Force);
        rigid.velocity = Vector3.ClampMagnitude(rigid.velocity, 18);
    }