Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
    
2) makes no sense whatsoever. You cannot detect a collision 'other than by using collision'. –  The Communist Duck May 23 '11 at 19:40
add comment

3 Answers

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.

share|improve this answer
add comment

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

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.