How do I bounce with 8Direction OR fix 0speed direction with Bullet Behavior?

0 favourites
From the Asset Store
Bouncing ball
$9.99 USD
Template for a bouncing ball game, fully documented in comments and video
  • Don’t use the behaviors. You can make the motion with events simple enough.

    Give the object you want to move two instance variables:

    Speed and ang. That’ll be your speed and angleOfMotion.

    Then the motion can be done with one event.

    Every tick

    — sprite: move self.speed*dt pixels at angle self.ang

    Then for the bounce it should be as simple as adding 180 to ang and moving out of the wall. Here’s what it should look like. The while and second overlap condition are in a sub event if that’s not clear.

    It moves out a pixel at a time but you can do a smaller step if needed.

    Sprite: overlaps wall

    — sprite: add 180 to ang

    ——while

    ——sprite: overlaps wall

    ——— sprite: move 1 pixel at angle self.ang.

    -cheers

    Hi there! Sorry for the long wait. I've implemented your idea, changed some variables, and ultimately polished and reorganized what I've done so far.

    Initially I thought that was a bad idea, instead it turned out that it's exactly what I wanted! Thank you so much for your help.

    As for now I'm doing great, eventually I'll let you know if I still have some issues.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hello! It's been a while.

    I promised that I would have noticy you for updates.

    Here's a short recap for whoever is reading:

    I'm making a top-down game in 4 directions.

    You're a robot vacuum cleaner, and your objective is to pick up the dust in levels.

    The robot will move automatically, while the player will just adjust the angle of direction, between up (270°), down (90°), right (0°), and left (180°).

    When the player hits a wall (either invisible or not), the robot "reflects" the direction.

    For example, if the player's direction is set to "right" and bounces on a wall, the new direction is set to "left".

    I had to make this premise because up to this moment, everything works as intended.

    I still want to thank R0J0hound for the suggestion.

    (Link: construct.net/en/forum/construct-3/how-do-i-8/bounce-8direction-fix-0speed-154535

    I still have their event. But there is a so-called bug I can't fix and is probably related to how the robot works.

    If the player spams against a wall in one direction, in a way or another, it will get stuck (if overlapping) or pass through it (if on collision). This happens only if the player makes a stress test, but I bet someone will do it just fine.

    Here you can see two videos:

    - dropbox.com/s/swrg9sarf9al9bl/10.06%20issue%20on%20collission.mp4 (collision)

    - dropbox.com/s/nu0az130nzbdjpm/10.06%20issue%20overlapping.mp4 (overlap)

    Is there any way to fix this? Thank you.

    UPDATE: Hello! Ok so, I say this for me and for the others as well:

    It's possible that I've fixed it by changing a parameter.

    If you look at R0J0hound's comment:

    "——— sprite: move 1 pixel at angle self.ang."

    I've changed from 1 pixel to 15, to leave enough space to not get stuck with the wall.

  • Ah, well moving 15 pixels instead of 1 would work but I think you missed what the original solution was.

    When a wall is hit it turns it 180 degrees.

    Then it does a loop to see if it’s overlapping a wall and move 1 pixel at a time till it’s out of the wall. That way it will move as many pixels as necessary to get out of the wall.

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