Skip to content

2D Tutorial: Normalize Vector Before Reflect #172

@AristurtleDev

Description

@AristurtleDev

Description

In the 2D Tutorial, the vector used as the normal for reflections for the bat is not normalized before reflecting. This can lead to a situation where a normal of (1, 1) creates an exaggerated reflection.

// If the normal is anything but Vector2.Zero, this means the bat had
// moved outside the screen edge so we should reflect it about the
// normal.
if (normal != Vector2.Zero)
{
    _batVelocity = Vector2.Reflect(_batVelocity, normal);
}

Reference

This was reported by a community member through via email. @SimonDarksideJ can add more info if needed

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions