Ball game physics questions

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
Coder567
Prole
Posts: 42
Joined: Sun Apr 07, 2019 12:32 pm

Ball game physics questions

Post 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!
User avatar
ivan
Party member
Posts: 1911
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Ball game physics questions

Post 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.
Coder567
Prole
Posts: 42
Joined: Sun Apr 07, 2019 12:32 pm

Re: Ball game physics questions

Post 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?
User avatar
ivan
Party member
Posts: 1911
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Ball game physics questions

Post 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
Coder567
Prole
Posts: 42
Joined: Sun Apr 07, 2019 12:32 pm

Re: Ball game physics questions

Post by Coder567 »

Ok
If anyone has code examples for my questions it would be great! :)

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

Who is online

Users browsing this forum: No registered users and 231 guests