- Home /
RigidBody2D - Ignoring other RigidBodies.
Hello everyone.
I've created 3 objects. One is the player, and the other 2 are obstacles.
Now, The game is viewed from the top of the scene, just like pokemon in gameboy.
I've got 1 issue.
I want my player to stumble upon one game object and walk over it while I want it to stumble upon the other one without being able to move.
Rigidbody2D allows me NOT move if the object is in my path, which is good, but I want to move across SOME objects, not all of them... And the idea is that they can collide with other objects that appear, is it possible to ignore some objects while blocking movement?
Here's how the player moves:
transform.Translate (Vector3.up * speed * Time.deltaTime);
So:
Player - RigidBody2D - BoxCollider2D (moves)
Object1 - RigidBody2D - BoxCollider2D
Object2 - RigidBody2D - BoxCollider2D
Thats the current setup for the 3 objects.
Answer by Pyrian · May 31, 2014 at 06:12 PM
So, Player collides with B, B collides with A, but A doesn't collide with the player?
What you want is something called Layers. You create them by going to Edit->Project Settings->Tags and Layers. Once you've got some shiny new Layers, you can assign them to objects at the top of each GameObject's inspector. Then, go to Edit->Project Settings->Physics 2D, where you can set checkboxes that determine which Layers collide with which other Layers.
Simple and powerful.