- Home /
Tilemap Collision Issues
I'm working on a game and using the new Tilemap features. They are working fantastic so far. So easy to whip up a level. However I am running into issues when reflecting a laser on the tilemap colliders. As you can see in the GIF below the first few lasers reflect fine, but the sometimes in the small crack where the colliders meet I am getting unwanted behaviour for my laser.
The laser is made up of a small pellet sprite renderer object with a trail renderer for the color behind and a circle collider.
Here is my collision code. Where direction is a class Vector2 variable and rb is theGameObject' s RigidBody2D component stashed in the Start()
function.
if (collision.collider.gameObject.layer == LayerMask.NameToLayer ("Terrain")) {
direction = Vector2.Reflect (direction, collision.contacts[0].normal);
rb.velocity = direction.normalized*GameManager.instance.bouncySpeed;
}
What steps can I take to avoid this behaviour?
Set collision detection mode of your laser to continuous.
Your answer
Follow this Question
Related Questions
Calculating vectors for two colliding objects 1 Answer
Boo & Collision 1 Answer
The tilemap collider is simply not working 0 Answers
Colliders not Working with Tilemap Generation! 0 Answers
Use RayCast2D with Tilemap collisions. 0 Answers