Stopping car from bouncing during collision

0 favourites
  • 13 posts
From the Asset Store
Bouncing ball
$9.99 USD
Template for a bouncing ball game, fully documented in comments and video
  • Hello guys,

    I have game where car is driving on the road. Then another sprite is wall and when I hit the wall with car I want the car not beeing able to drive through the wall. I though I got it right but my method sometimes does not work and someties car somehow go through wall.

    Car has variable "way". When way is 0 car is going backwards when way is 1 car is going forward. I did that so I know if car goes backwards or forwards. In conditions I have this:

    <img src="http://img822.imageshack.us/img822/927/wallcolision.jpg" border="0" />

    Most of the time it works. However sometimes car gen go through the wall and I dont know. Do you know what could be the problem?

    The wall is not sprite but tiledbackground.

    Thank you

  • You don't need to create event's for the wall. u only need to give it behavior "solid" and that should work.

  • Well that is exactly what I dont want. Because if you create wall as solid and then car has collision with it it bounce like crazy :)

  • Add an event that says when the car collides with a wall set the cars speed to zero.

  • Add an event that says when the car collides with a wall set the cars speed to zero.

    Unfortunately this does not help as well :/ It must be something else. As I said most of the time 90% it works. But sometimes when my speed is too high or if I hit the wall and then try to turn my car to the side and collide with wall by car's side it goes through

  • I uploaded capx to dropbox if anyone would be interested in helping me out :)

    https://dl.dropbox.com/u/97534866/testing.capx

  • Give the fence a solid behavior then on collision with fence set car speed to lerp(player.Car.Speed,50,0.8). You can play around with the numbers, I'm not sure what I'm doing but it seemed to work for me <img src="smileys/smiley17.gif" border="0" align="middle" />

  • Give the fence a solid behavior then on collision with fence set car speed to lerp(player.Car.Speed,50,0.8). You can play around with the numbers, I'm not sure what I'm doing but it seemed to work for me <img src="smileys/smiley17.gif" border="0" align="middle" />

    Thank you but it did not help either :).

    I somehow cannot believe nobody here knows how to do standard car collision with wall :)

  • Don't use a tiled background, use several instances of the same sprite with an adapted collision polygon.

    Also you might want to use the condition "is overlapping at offset" to anticipate the collision, and not just react to it as with a "on collision" trigger.

  • I don't see any "crazy bouncing" using the solid behaviour:

    Michal11.cpax

  • I don't see any "crazy bouncing" using the solid behaviour:

    Michal11.cpax

    Thank you. Well try to hit the wall with front bumper and keep holding up arrow and you will see. It is not like bouncing but more like sliding to the side. The interesting thing is that in the example you sent me if I drive backwards it works perfectly fine :)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Don't use a tiled background, use several instances of the same sprite with an adapted collision polygon.

    Also you might want to use the condition "is overlapping at offset" to anticipate the collision, and not just react to it as with a "on collision" trigger.

    unfortunately it still does same problems. Sometimes if you angle of car is at certain position you can go through the wall

  • I hope this is what you were after. I gave the fence a solid behavior and then adjusted your events so that if the car is not overlapping the fence then the back and forward keys will work.

    dl.dropbox.com/u/93923432/car.png

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)