Phaser home
Phaser AE
Open source
Phaser 4
Download
Learn
Editor
Tools
Docs
Examples
News
Log in
Examples
/
Math
/
Vec2
Phaser 4.1.0
Phaser 4 examples
Vec2
9
examples
Examples
9
Normalize Vector2
Demonstrates how to normalize a Vector2 to create a unit vector (length of 1) and scale it to a fixed magnitude regardless of the input distance.
Set Vector Magnitude
Demonstrates how to fix the length of a Vector2 to a specific value using the setLength method while maintaining its direction.
Vector2 Add
Demonstrates how to add one Vector2 to another to translate a point's position in a loop.
Vector2 Division
Demonstrates dividing the components of a 2D vector to create a sequence of points based on pointer position.
Vector2 Dot Product
Demonstrates how to calculate the dot product between two vectors to determine the angle between them and their relative orientation.
Vector2 Multiply
Demonstrates how to multiply Vector2 components iteratively to create a visual pattern based on pointer movement.
Vector2 Perpendicular
Calculate and visualize a perpendicular vector using the normalizeLeftHand method, which rotates a Vector2 by 90 degrees relative to its origin.
Vector2 Right Perpendicular
Demonstrates how to calculate a vector perpendicular to another by rotating it 90 degrees clockwise using the normalizeRightHand method.
Vector2 Subtract
An example of manipulating the x and y properties of Vector2 objects over time to create a scrolling wave effect.