Beispiel #1
0
    private void DisplayPreCollisionDetails(Collision2D collision)
    {
        Vector2 oldVelocity1, oldVelocity2;

        PhysicsHelper.CalculatePreCollisionVelocity(
            collision,
            out oldVelocity1, out oldVelocity2
            );

        SceneViewLabel.SetText(
            gameObject,
            "oldVelocity1: " + oldVelocity1.ToString("F2") +
            ", oldVelocity2: " + oldVelocity2.ToString("F2")
            );
    }
Beispiel #2
0
    private void DisplayDetails(string prefix, Vector2 relativeVelocity)
    {
        var body = rigidbody2D;

        if (body != null)
        {
            if (!string.IsNullOrEmpty(prefix))
            {
                prefix += " ";
            }

            float impulse = body.velocity.magnitude * body.mass;

            SceneViewLabel.SetText(
                gameObject,
                prefix +
                "velocity: " + body.velocity.ToString("F2") +
                ", impulse: " + impulse.ToString("F2") +
                ", relativeVelocity: " + relativeVelocity.ToString("F2")
                );
        }
    }