- Home /
physics for 2D game
I have a character controlled object that moves 1 unit up, down, left or right depending on the arrow keypad. I am not using gravity for this object, but when in runs into a solid object it starts to float in 3d space. If I make it kinematic, it goes right through objects. I want it to simply collide with the objects but not start floating, what's the best way to do this?
And I need you to not ask so many questions in one post. Read the FAQ in its entirety: http://answers.unity3d.com/faq And next time, ask one, specific question in your post, that someone can answer for you. "How do I...?" questions are good questions to ask, so long as you make them as specific as possible.
Answer by Gary · Jul 15, 2010 at 12:57 AM
I am not sure what you mean by 'it starts to float in 3d space'. I assume 2D game is simply a 3D game with camera held fixed in a 2D plane, so everything is in 3d space anyway. If I understand correctly you wish to control this object precisely, but the moment you collide it with another object it bounces away in opposite direction thanks to physics... is this what you mean by float in space ?
If that is the case maybe you can start with 'Is Kinematic' disabled initially and enable kinematic after the collision has taken place and then control it precisely through your script? You will need to detect the collision through your script of course. And maybe then you can again disable kinematic? This might trick it into holding the object in place after the collision. Also maybe you can increase the mass of your object to some really high number to prevent it from bouncing off into space. I don't know if this will work but all I can think of..
Also this might come in handy : http://answers.unity3d.com/questions/1548/how-do-i-detect-a-collision-without-affecting-the-physics
Yes that is what I meant, thanks for the advice, I just have to find the right script I guess.