Page 1 of 1

Ball game physics questions

Posted: Wed Sep 25, 2019 11:38 am
by Coder567
Hi
I was looking to the love physics and I think that's great for my game. However I have couple of questions if anyone knows good way to go about it.

First I'm making a sport game where there is walls around the play area which the ball cannot pass but should bounce back (and I'm going to use love physics for this). And in game the players carry around the ball but what if the ball touches the border? How do I combine the physics engine with players being able to carry the ball with them?

Second question, is there a function to check when the ball crosses the goal line?

thanks!

Re: Ball game physics questions

Posted: Wed Sep 25, 2019 1:25 pm
by ivan
How do I combine the physics engine with players being able to carry the ball with them?
Use applyImpulse and applyTorque.
Do not change the velocity or position manually.
is there a function to check when the ball crosses the goal line
Box2D has collision callbacks and contact lists.
For things like triggers and sensors, use the latter.

Re: Ball game physics questions

Posted: Wed Sep 25, 2019 1:30 pm
by Coder567
Use applyImpulse and applyTorque.
Do not change the velocity or position manually.
I guess I could do that but it complicates things. easier to just set the position than trying to aim with vector ;)

Box2D has collision callbacks and contact lists.
For things like triggers and sensors, use the latter.
Is box2D in love.physics?

Re: Ball game physics questions

Posted: Wed Sep 25, 2019 1:35 pm
by ivan
Coder567 wrote: Wed Sep 25, 2019 1:30 pmeasier to just set the position than trying to aim with vector
In that case, don't expect your ball to react to other objects ;)
Coder567 wrote: Wed Sep 25, 2019 1:30 pm Is box2D in love.physics?
Yes

Re: Ball game physics questions

Posted: Wed Sep 25, 2019 2:24 pm
by Coder567
Ok
If anyone has code examples for my questions it would be great! :)

Edit: Found Fixture:setSensor( true ) - for the goal line