Abhishek Bharti Posted April 14, 2016 Share Posted April 14, 2016 Hello, I am having problem rotating box2d object back and forth around a point. To better understand my problem i have prepared an example clicking on key rotate the paddle when u click again the paddle rotate back to its initial position. http://abhishekbharti.pe.hu i want to simulate something like this in box2dWeb. Thanks in advance Quote Link to comment Share on other sites More sharing options...
Milton Posted April 14, 2016 Share Posted April 14, 2016 Maybe look at http://phaser.io/examples/v2/box2d/pinball Looks like revoluteJoint is what you want. Quote Link to comment Share on other sites More sharing options...
Abhishek Bharti Posted April 14, 2016 Author Share Posted April 14, 2016 I tried revoluteJoint along with enabling limit and setting LoweAngle. I got upto 50% what i want but i cant make the paddle go back to its initial position bcz gravity keep it pushing down. Quote Link to comment Share on other sites More sharing options...
Milton Posted April 14, 2016 Share Posted April 14, 2016 Hmm, maybe use a kinematic if you don't want gravity. Or look at body->SetAwake(false);http://box2d.org/forum/viewtopic.php?f=18&t=7117 I'm just guessing here, I know nothing about Box2D, I prefer Nape Quote Link to comment Share on other sites More sharing options...
Abhishek Bharti Posted April 14, 2016 Author Share Posted April 14, 2016 (SOLVED) finally i solved the puzzle, To get the paddle back to its initial position i just need to counter gravity by applying force to that paddle in opposite direction of gravity like this: body.ApplyForce(body.GetMass()*-world.GetGravity(), body.GetWorldCenter()); need to apply this force every frame. This article here helped me: http://www.iforce2d.net/b2dtut/custom-gravity Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.