Let a car bounce of boundaries

  • Hello! I tried a few things with car and/or bullet behaviors but could not get it right, yet. Maybe some experienced users know how to fix it?

    I have a player sprite (car) inside another big sprite which acts as boundary for the level. After a few experiments with settings and how to do it I managed to let it bounce off the wall with the bullet behavior and actions. But sometimes the player sprite gets stuck at the wall and is spinning around the whole time.

    Here is the code for it so far:

    <img src="http://img5.fotos-hochladen.net/uploads/bounceprobd16yz74vb3.jpg" border="0" />

    Does anyone know how to fix this?

    And is it possible to export a single layout instead of the whole project to post an example?

    ps: when I let the sprite bounce off with bullet behavior and speed 0 I get an error popup in chrome:

    <img src="http://img5.fotos-hochladen.net/uploads/bounceerror0spq8c7huv6r9.jpg" border="0" />

  • The collision polygon is used to define the outside of a sprite, you are trying to bounce of the outside, but inwards, that is obviously a strange thing to do, bouncing into a solid object.

  • Right, but it seems to work in many cases. Only sometimes when Car+Bullet are combined on one sprite it gets "stuck" and swirls around. But other times it works like I want it and bounces back with the proper angle and speed. I will try to copy all elements in a new project to post a .capx.

    /Update: Here is an example.

    dl.dropboxusercontent.com/u/26714455/CarBullet_Bounce.capx

  • What is the benefit of doing it in a different way than the intended one?

    Why try to make it work this way when there is a perfectly good solution to do it that is not only easier, but also less prone to unwanted behaviour?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I found another example in the forums where someone used this method and it worked for him. But I did not try it with several boundary sprites yet because it was easier to just draw the outlines in one sprite.

    I will try if the swirly behavior is gone when I use separate sprites for each "wall" of the level and collision without overlapping.

  • I tried it with "normal" bouncing on contact and it seems to work fine from the left side. But if you go around and hit the wall from the right something strange happens. The sprite does not bounce off and is stuck at the wall. o.O

    Example: dl.dropboxusercontent.com/u/26714455/CarBullet_Bounce2.capx

  • Any ideas why it is not bouncing of when it comes from the right side or below?

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