Hello, I am creating a 2D room where the walls are box colliders. I have an object in the room that has a box collider and a rigid body component, I am changing the gravity direction based on the accelerometer. that works, but
It seems that i cant move the player (with the box collider) after it has rested on one of the walls, or touched 2 walls, like in a corner. is it constantly in a collision loop or whats going on. i want to be able to flip the accelerometer around again and it would drop down again, but it just gets stuck. when i try to change its location programmatically to some other place where its not touching the wall, it seems to move again.
Please post all of your code.
Answer by ryanbuddy1
Jul 15, 2011 at 02:13 PM
You will need to add force in the upward direction of your box when trying to move it as it is probably getting stuck in one of the walls of your level.
Put the below in script when you press a button to move your character and it should work:
rigidbody.AddForce (Vector3.up * 10);
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
To help users post good questions and use the site effectively we have posted a user guide. Please check it out.
Answers and Comments
1 Person is following this question.
Fast moving objects 2D game
Make Character Controller a Box?
Unwanted results from 2D collisions?
Collision detection not working properly with 2D sprites
Unity2D Specific Collider Detection?