unity3d - How to move an object without going through colliders -
i'm using unity
, doing pong game. able move paddles mouse key. have tried moving position of course "teleport" them through colliders along edge of playing field. tried using addforce()
, making rigidbody fixed in x position, however, happens when ball hits paddle, pushes , paddle snaps back. of ball's energy lost (there gravity in game). how can move box collider not let on lap other box colliders while moving? thanks!!!
your paddle should kinematic (iskinematic parameter) rigidbody (attached rigidbody2d) collider while edges should static collider. but, should control limits/edges of paddle movement within script.
if things way, ball naturally bounce of edges , off paddle. if, however, want ball pass through edges notify of doing (e.g. lose condition), should make edges static trigger collider (istrigger parameter).
here's detailed list interactions between different types of colliders: http://docs.unity3d.com/manual/collidersoverview.html. messages generated passed via 2 different functions: ontriggerenter2d , oncollisionenter2d.
Comments
Post a Comment