# How to make a G.O. move like this?

#1

Hi … I am new with defold and I love it
I have a little problem here

I need to give the ball a certain speed (the speed bigger than the speed of player object) and let it moves in the direction of green arrow

3 Likes

#2

I’m not really good with kinematics but I would do it the following way:

impact by player from the balls point of view:

1. process collision message and determine impact velocity(speed and direction).
2. apply any scaling to the velocity determined by mass differences or however you want to do this.

When the ball hits the wall from the balls point of view:

1. process collision message and determine the impact angle in relation to the wall and any speed changes
2. Mirror that angle across the impact point and apply the speed.

I think you will find some of the code your looking for in the breakout game example on this page.
http://britzl.github.io/publicexamples/

2 Likes

#3

Yes, my Breakout example deals with bouncing kinematic balls, as does my Pong clone.

3 Likes

#4

Cool Pong Clone! I ran into a bug though. The ball got stuck by the AI’s paddle.

0 Likes

#5

Oh, ok. Can we call that a feature?!

6 Likes

#6

@britzl Why you didn’t use dynamic physics with applying force? In this way I found that ball’s physics is more realistic. Could you explain your decision?

MY SETUP

ball.go
collision_type: dynamic
mass: 0.075
friction: 0
restriction: 1

ball.script

``````msg.post("#collision_object", "apply_force", { force = vmath.vector3(5000, 5000, 0), position = go.get_world_position() })
``````

game.project
gravity_y: 0.0
scale: 0.02

1 Like

#7

The purpose of the example was to show bouncing kinematic balls.

2 Likes

#8

Hi @britzl, thank you for reply. Can you help me? Why if I using dynamic collision my ball not collide with paddle from the paddle’s edge? Is any way to fix it?

0 Likes

#9

Have you enabled physics debug in game.project? Does the collision shapes look ok?

0 Likes

#10

Yes. You can see collision shapes in the second screenshot.

0 Likes

#11

I can share github repo if you need.

0 Likes

#12

Have you double checked the collision masks for both objects?

1 Like

#13

After enabling it, the shapes look.

0 Likes