I am currently working on a 2d puzzle game in the unity engine. One of the aspect of this game is the possibility to rotate the level of 90°. It also rotate the gravity.

The main character is not directly controlled by the player, but instead falls when the level is rotated.

When the main character hits a wall, he should stop to moving. If I do not stop it, it kind of blinks and shakes against the wall.

To stop it I detect collision and depending on the current rotation state, the player will stop at "vertical" or "horizontal" tags when a OnCollisonEnter occurs. I must do that because when the player falls on his relative ground, he must not stop like if he had touched a wall.

My problem is the 'side' of platform, or the 'top' of wall, they use the same tag and thus do not give the correct tag to my character. I tried to put a very small invisible box on top/side of elements but the collision occurs nevertheless. It seems when the player falls and hit something he go through a bit before being replaced at correct position by unity.

Is there a way :

1 ) to not stop my character but to make it appear immobile on screen

2 ) To detect a "I cannot move anymore" collision other than by using collision?

  • \$\begingroup\$ 2) makes no sense whatsoever. You cannot detect a collision 'other than by using collision'. \$\endgroup\$ Commented May 23, 2011 at 19:40

3 Answers 3


Perhaps your "walls" should be made of 4 planes, each of which has the appropriate horizontal or vertical tags.


I must admit, I don't see anything that should pose problem here in unity.

You can just have your walls as static colliders that you place manually, and use a capsule collider for your player. The Unity Platform tutorial is good even if it is in JS for the most part, and may help you with collisions.

The problem of the character "blinking" seems to me that it is just a physics problem (maybe the character is too small or too large). You should NEVER manually set the x / y position of something when using a physics engine, you need to let it do it's job.

Although to try and answer your questions :
In Unity you can create different Tags, which you can check on a collision. This means you can tag colliders that have special properties, and in your collision code check gameObject.transform.tag == "YourTag". You should be able to differentiate the vertical and horizontal walls this way.

In response to 2) :
If you do not want to use Physics, but still use collision detection, your objects have to be static, and you need to set the colliders as Triggers. This also means in your code you have to use OnTriggerEnter() / Exit, etc.

"It seems when the player falls and hit something he go through a bit before being replaced at correct position by unity."

To counter this problem, you could reduce your physics time-step in the Physics properties of the game, or make the number of iterations higher.


1) i'm not sure but if you change you object from dynamic to static should do the trick, since static objects can't move even if they have some speed

2) not knowing a way to tell flag "i cannot move anymore" but you can always check wheather the speed or at least average speed of 1 past second is less than somthing that would happen only if you spot the character or it stuck somewhere in walls.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .