I moved to a new URL! Check it out!

Otter Example: More Collisions

Otter Example: More Collisions
Hot of the presses with a new Otter example! This example goes over more of the collider types that can be used in Otter. In total Otter has a Box, Circle, Grid, Polygon, Pixel, Point, and Line collider, and this example will cover all of them except for the Pixel collider (because that one should be used very sparingly anyway.)

Here's a quick preview of the code that can be found in the example:
class PolygonTest : Entity {

PolygonCollider polygonCollider;

public PolygonTest(float x, float y) : base(x, y) {
// Create a PolygonCollider and give it some Vector2 points.
polygonCollider = new PolygonCollider(
new Vector2(0, 0),
new Vector2(80, -10),
new Vector2(30, 90),
new Vector2(-5, 15),
new Vector2(0, 5)
);

// Add the Walls tag (since this isn't in the constructor.)
polygonCollider.AddTag(Tags.Walls);

// Set the rotation to a random angle.
polygonCollider.Rotation = Rand.Angle;

// Add the Collider.
AddCollider(polygonCollider);
// Center the origin of the Collider.
polygonCollider.CenterOrigin();
}

public override void Render() {
base.Render();

// Render the Collider for debug purposes.
polygonCollider.Render();
}
}
The full example places a bunch of colliders in a scene with a moving object to test collisions with.

Image


A lot more examples are on the way!
new comment!

Post your comment!

Name
Email
Comment