Unity, changing gravity game & stopping character when he hit a wall.

Posted by Sylario on Game Development See other posts from Game Development or by Sylario
Published on 2011-05-23T16:27:13Z Indexed on 2011/06/23 0:33 UTC
Read the original article Hit count: 235

Filed under:
|

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 fall when the level is rotated.

When the main character hit a wall, he should stop to move. If i do not stop it, it kind of blink ans shake 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 fall on his relative ground, He must not stop like if he had touch 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 doesn't 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?

© Game Development or respective owner

Related posts about collision-detection

Related posts about unity