Ejemplo n.º 1
0
        protected override void CalculateVelocity(InputSet input)
        {
            Vector3 bForce = bodyForce.CalculateForce(velocity);
            Vector3 lForce = leftWingForce.CalculateForce(velocity);
            Vector3 rForce = rightWingForce.CalculateForce(velocity);
            Vector3 tForce = tailForce.CalculateForce(velocity);

            if (updateVelocity)
            {
                AddVelocity(bForce, input.rigidbody.mass);
                AddVelocity(lForce, input.rigidbody.mass);
                AddVelocity(rForce, input.rigidbody.mass);
                AddVelocity(tForce, input.rigidbody.mass);
                AddVelocity(Physics.gravity, 1);
            }
        }
Ejemplo n.º 2
0
        protected InputSet CreateSet()
        {
            InputSet set = new InputSet();
            set.bodyTransform = transform;
            set.xDelta = Input.GetAxis("xRot") * xSens;
            set.yDelta = 0f;
            set.zDelta = -Input.GetAxis("zRot") * zSens;
            set.gravity = Physics.gravity;
            set.deltaTime = Time.deltaTime;
            set.invertVertical = true;
            set.openWings = 1f - Mathf.Abs(Input.GetAxis("wingOpen"));
            set.rigidbody = GetComponent<Rigidbody>();
            set.leftWingTransform = leftWing;
            set.rightWingTransform = rightWing;
            set.tailTransform = tail;

            return set;
        }
Ejemplo n.º 3
0
        protected virtual void CalculateVelocity(InputSet input)
        {
            // Calculate new velocity
            input.rigidbody.AddForce(bodyForce.CalculateForce(input.rigidbody.velocity));
            input.rigidbody.AddForceAtPosition(leftWingForce.CalculateForce(input.rigidbody.velocity, input.openWings), input.leftWingTransform.position);
            input.rigidbody.AddForceAtPosition(rightWingForce.CalculateForce(input.rigidbody.velocity, input.openWings), input.rightWingTransform.position);
            input.rigidbody.AddForceAtPosition(tailForce.CalculateForce(input.rigidbody.velocity), input.tailTransform.position);
            input.rigidbody.AddForce(Physics.gravity, ForceMode.Acceleration);

            // debug
            if (Game_Debug.Info.DebugDisplayLevel == Game_Debug.Info.DisplayLevel.All)
            {
                Debug.DrawLine(transform.position, transform.position + input.rigidbody.velocity, Color.green, 0f, true);
            }
            else if (Game_Debug.Info.DebugDisplayLevel == Game_Debug.Info.DisplayLevel.Light)
            {
                Debug.DrawLine(transform.position, transform.position + input.rigidbody.velocity, Color.green, 0f, true);
            }
        }
Ejemplo n.º 4
0
        protected void SetDefaults(InputSet input, FlyingCreature creatureType)
        {
            defaultLeftWingRotation = input.leftWingTransform.rotation;
            defaultRightWingRotation = input.rightWingTransform.rotation;
            defaultTailRotation = input.tailTransform.rotation;
            creature = creatureType;

            bodyForce = new ForcePoint(creature.FrontArea, creature.TopArea, creature.SideArea, creature.DragCurve, creature.LiftCurve, input.bodyTransform);
            leftWingForce = new ForcePoint(0f, creature.WingArea, 0f, creature.DragCurve, creature.LiftCurve, input.leftWingTransform);
            rightWingForce = new ForcePoint(0f, creature.WingArea, 0f, creature.DragCurve, creature.LiftCurve, input.rightWingTransform);
            tailForce = new ForcePoint(0f, creature.TailArea, 0f, creature.DragCurve, creature.LiftCurve, input.tailTransform);
        }
Ejemplo n.º 5
0
 protected void RotateWings(InputSet input)
 {
     input.leftWingTransform.localRotation = defaultLeftWingRotation * Quaternion.Euler((input.xDelta + input.zDelta) * 10f, 0f, 0f);
     input.rightWingTransform.localRotation = defaultRightWingRotation * Quaternion.Euler((input.xDelta - input.zDelta) * 10f, 0f, 0f);
     input.tailTransform.localRotation = defaultTailRotation * Quaternion.Euler(-input.xDelta * 10f, 0f, 0f);
 }