[Solved] HELP, im making soccer game and my ball goes through barrier!?

**How do I make my ball bounce of my static barrier? it has a 2d physics behaviour

and the type is set to static, my player and ball has the same behaviour but type is set to dynamic.

**so i want my player to just not be able to go past the barrier but the ball to bounce off it **

when the game runs i want there to be one player vs an ai player and when you run with the ball it goes with it only if in collision.

**but instead my player will my player and ball at first they wont go through but when i apply a force because the player is kicking the ball it will go right through and if i make the player move it will also go out. **

(plz help) :pleading_face:

That add force action is not a physics action and ignores the physics rules. You can tell by the icons. This is the icon for a physics force action:

image

and this is the icon for a non-physics force action:

image


To add a physics force, you need to look under the Physics options in the object’s actions:

2 Likes

Can u give me an example of which one i should use? because i was doing what the Gd AI bot said.

It depends on how you are moving the players. If it’s using physics forces, then stick with physics actions.

But if you are moving the player by changing the screen position, either in events or with a behaviour (like top-down or platformer), then you should create events to handle the collision between ball and walls.

1 Like

Im doing top down but physic forces not following the player with camera

Sorry, can you clarify. Is it a top-down viewed game, or are you using the top-down behaviour?

If it’s just the view, then change the forces to physics.

If it’s behaviour, then you need to decide on either top-down behaviour with non-physics forces or physics. But not both as they have a habit of creating unwanted effects.

1 Like

I am using “TopDownMovement” behaviour and also the “2dPhysis” behaviour.

If you don’t add physics behaviour to the players, then you might get away with using physics forces on the ball.

But you may find strange behaviour when the player collides with the ball.

1 Like

oh hmm, well what do u recommend me to do?
(i was just doing what the Gdevelop AI bot was telling me 2 do)

i dont understand what it means do i do the add force (angle) or do i do apply impulse?

Resolved thank you. It works now. i Did the stff u told me to do. :slight_smile:

1 Like