Example #1
0
    private void OnCollisionEnter(Collision collision)
    {
        GameObject projectile = collision.collider.gameObject;
        Boolean    destroy    = false;

        HapticAttributes      hapticAttributes      = projectile.GetComponent <HapticAttributes>();
        TemperatureAttributes temperatureAttributes = projectile.GetComponent <TemperatureAttributes>();
        EMSAttributes         emsAttributes         = projectile.GetComponent <EMSAttributes>();

        if (hapticAttributes != null)
        {
            HapticFeedback(hapticAttributes, collision);
            destroy = true;
        }

        if (temperatureAttributes != null)
        {
            TemperatureFeedback(temperatureAttributes, collision);
            destroy = true;
        }

        if (emsAttributes != null)
        {
            EMSFeedback(emsAttributes, collision);
            destroy = true;
        }


        if (destroy == true)
        {
            Destroy(projectile);
        }
    }
Example #2
0
    private void EMSFeedback(EMSAttributes emsAttributes, Collision collision)
    {
        Module module = moduleByType[ActuatorType.EMS];

        if (module == null)
        {
            Debug.Log("ERROR: module not found");
            return;
        }

        int[]     values         = moduleValues[module];
        Vector3[] actuatorPoints = module.getPositionOfActuators();

        for (int actuator = 0; actuator < module.count(); actuator++)
        {
            Vector3 closestPointOnColliderInDirectionActuator = collision.collider.ClosestPoint(actuatorPoints[actuator]);

            float distance = Vector3.Distance(actuatorPoints[actuator], closestPointOnColliderInDirectionActuator);
            float f        = attenuation(distance) * emsAttributes.ExpectedEMS;

            values[actuator] = (int)f;

            QueueValues(module.ID, values);
        }

        nextEMSStep = 0f;
    }