Hello all!
I'm starting to make a single game in LOVE 2D(Pong) and I'm struggling in the following things:
- Problems on inverting direction when a ball collides on paddle --> The ball goes in one direction, but on the beginContact() function I inverted direction but still don't work;
- In the collision of the ball and the paddle the ball pushes the paddle off the screen --> I'm thinking the reason is that the ball direction don't invert, but I want to avoid all kind of impulse to be applied on the paddle.
I've searched and I don't know what to do. Thanks in advance guys :awesome !!!
P.S.: Together I sent my main.lua file.
Problem while inverting direction on collision
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 3
- Joined: Thu Apr 19, 2018 1:20 pm
Problem while inverting direction on collision
- Attachments
-
- main.lua
- (4.62 KiB) Downloaded 104 times
Re: Problem while inverting direction on collision
I think you're gonna have a hard time making Pong work with accurate physics simulation, and you would be better off making your own ball and paddle 'physics' that is better suited for this type of game.
Re: Problem while inverting direction on collision
Depends on the mass and velocity of the objects. Heavier bodies tend to push lighter bodies, that's just how physics works. A naive solution could be increase the density of the paddle.BagarraoEduardo wrote: ↑Thu Apr 19, 2018 7:05 pm - In the collision of the ball and the paddle the ball pushes the paddle off the screen -->
If you set the type of the paddle to "kinematic" it won't respond to collisions at all.
Alternatively, a prismatic joint can constrain motion to a specific axis.
Also, make sure the "restitution" coefficient of both the paddle and ball is set to "1".
-
- Prole
- Posts: 3
- Joined: Thu Apr 19, 2018 1:20 pm
Re: Problem while inverting direction on collision
Yeah you're right I'll started that way but I thought it would be a bad approach, but I'll make it again from scratch ty
-
- Prole
- Posts: 3
- Joined: Thu Apr 19, 2018 1:20 pm
Re: Problem while inverting direction on collision
I'll make the game from scratch without the physics, I only don't know how I'll apply the collisions in that way ty anywayivan wrote: ↑Fri Apr 20, 2018 6:52 amDepends on the mass and velocity of the objects. Heavier bodies tend to push lighter bodies, that's just how physics works. A naive solution could be increase the density of the paddle.BagarraoEduardo wrote: ↑Thu Apr 19, 2018 7:05 pm - In the collision of the ball and the paddle the ball pushes the paddle off the screen -->
If you set the type of the paddle to "kinematic" it won't respond to collisions at all.
Alternatively, a prismatic joint can constrain motion to a specific axis.
Also, make sure the "restitution" coefficient of both the paddle and ball is set to "1".
Who is online
Users browsing this forum: Google [Bot] and 4 guests