I have a pong type of game in which you have to keep the ball from reaching the bottom, but I don’t know how physics in Defold works, so, I need help in how the ball can bounce from the paddle.
Here’s the manual explaining how physics work:
And here are some examples:
I have read the manuals, and I still can’t quite figure out how to make the ball bounce, I tried but the ball just goes through my walls and the paddle at a very high speed, I even turned on the bullet property and it still doesn’t work. The mask and group properties are set correctly for the collisions, but the ball still goes through like I said.
Are you using dynamic type for the ball? What does it look like when you enable physics debugging in game project settings? Are the collision shapes where you expect them to be?
Sorry for not responding, I have been busy, I’m going to send a photo of physics debugging.
I can’t quite catch the ball it immediately falls off the screen, but when I set the ball and the other collisions to different masking the ball falls off the screen but less fast
the image is not on my desktop even if i take more??
Yes I’m using dynamic type for the ball, and the collision shapes should be where I expect them to be.
This is my script for the bouncing ball technique
function init(self)
msg.post(".", "acquire_input_focus")
end
local function bounce_ball(self)
local ball_velocity = go.get("#ball", "linear_velocity")
ball_velocity.y = -ball_velocity.y --
go.set("#ball", "linear_velocity", ball_velocity)
msg.post("gui#gui", "hello")
end
function on_message(self, message_id, message, sender)
if message_id == hash("contact_point_response") then
if message.other_id == hash("Paddle") then
bounce_ball(self)
end
end
end
My game is a school project, to learn how people make games and I chose to make a simple pong game, but I dont wanna use a tutorial as it ruins trial and error.
@britzl I have dynamic type for the ball and the collision shapes are where I expect them to be, but when I set the ball to the Paddle or Wall mask, the ball goes very fast off the screen. Can I send you the game?
I’m sorry I don’t know how to send the Defold file; I can’t find it anywhere in my desktop.
You can pack the whole project directory into zip and attach it here
For example 7zip. Windows have now even zipping built-in.
If you don’t know where your project directory is on your computer you can try this:
It will open your project directory in system explorer. You can go one level up and zip the whole catalog
I have sent the file so you guys can see what is wrong with my game.