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

From the Asset Store
This pack contains 10 types of bullet effects, with different shapes and colors.
  • Hi, I didn't want to ask for help again, but here we are...

    Ok so, I'm making a 4 direction game, in which the character reflects the walls. Meaning if the characters goes to right, and hit the wall, automatically goes to the left, and so on.

    At first, I immediately thought to use the bullet behavior for the character.

    And in a sense, it works. But there is a problem.

    If the character has the speed set to 0, you can't change the direction to either up or down, but just left or right. This, only when the speed is set to 0. In the game, after you choose a direction, the speed goes automatically to 150.

    Since it looked a specific issue, I tried with my trials and errors, but I haven't found anything that could work.

    ______________________

    So now I've tried using another method, which is 8Direction (limited to 4).

    In this case, I literally had no issues with moving and choosing the directions.

    But.

    Now the character can't reflect the walls properly.

    With the bullet behavior, I can easily use the "Bounce of Solids" option.

    While with 8Direction I have to add a "Reverse 8Direction" action when the player collides with the wall.

    As a result: If the character starts and goes to right (angle of motion 0°), hits the wall and it successfully goes to the left (angle of motion -180°). But when the character hits the left wall, it goes down (angle of motion 90°).

    If the character starts and goes up (angle of motion -90), hits the wall and goes to the left (angle of motion -180°), and hitting the left wall, the character goes down again (90°).

    I'm probably considering the angles in the wrong way, but at the moment I have no clues on what to do.

    Do you think would be better for me to continue with 8Direction or Bullet behavior? And how can I fix one of the two?

    Thank you.

  • "If the character has the speed set to 0, you can't change the direction to either up or down, but just left or right. This, only when the speed is set to 0. In the game, after you choose a direction, the speed goes automatically to 150." Is that true?

  • "If the character has the speed set to 0, you can't change the direction to either up or down, but just left or right. This, only when the speed is set to 0. In the game, after you choose a direction, the speed goes automatically to 150." Is that true?

    Here's a video with the *bullet* behavior on.

    dropbox.com/s/0gf2grs7mogw8b3/2020-08-16%2001-02-41.mp4

    Watch both the direction of the mouse and the particles I've added to the character.

    This game is meant for mobile, so I'm doing swipes.

    If you're wondering, yes, I've tried changing the swipes with the keyboard commands, but nothing changes.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Shoot.

    I posted this on Construct 2.

    My bad...! Is it possible to move the question on Construct 3?

  • Not really sure what I'm looking at, only you know the game. It's a sprite bouncing left to right off solids, what's the issue? What is meant to happen that is not happening? Are all the relevant events visible in the video?

  • Not really sure what I'm looking at, only you know the game. It's a sprite bouncing left to right off solids, what's the issue? What is meant to happen that is not happening? Are all the relevant events visible in the video?

    Yes, all the relevant events are visible in the video.

    With the bullet behavior:

    If the character is created, bullet speed is set to 0.

    If I press arrow down, the bullet speed is set to 150 and the bullet angle motion is set to 270 degrees.

    The issue is:

    In game, at the very beginning, when the character has bullet speed set to 0, if the player presses arrow down, the character does not move down, but right.

    This, only when the character has 0 bullet speed.

    If I let the character stop (returning to 0 bullet speed) the issue returns.

    __________________________

    Anyway, if it's too hard to solve, I'm ok to use the 8Direction behavior, but I don't know how to make a bouncing effect similar to the bullet behavior.

  • I don't think they are visible, I don't see any events relating to movement of the character from those mouse clicks or keyboard presses.

  • I don't think they are visible, I don't see any events relating to movement of the character from those mouse clicks or keyboard presses.

    AH-ehm, ok.

    dropbox.com/s/twhpdn2qzp2wj4m/test2%281%29.c3p

    Again, if the bullet behavior isn't ok, I can just use 8Direction.

    Just... I don't know how to make the character reflect position after hitting the wall.

  • Swap the speed and angle of motion actions around so speed is first

  • Ok... It worked. I... Thank you so much for your help.

    I've been in contemplation for hours, I knew something was wrong in that event, but I didn't know what and how... I'll pay more attention in the future.

    I'm still interested to know if there is a way to allow bouncing with 8Direction (for the future), but as for now I'll leave it in this way.

    Thank you.

  • Yes you simulate control and when on collision with something you reverse the direction. But that only makes sense if it moves on its own.

  • Yes you simulate control and when on collision with something you reverse the direction. But that only makes sense if it moves on its own.

    Yeah it's 50/50, since you don't need to hold the button to move the character, but you definitely choose the direction. The reverse direction doesn't work always, while bounce off solids does with bullet behavior.

  • Moved to the C3 section as per request.

  • Hi, I'm back because I have a question.

    In the end, my character can swipe thanks to the bullet behavior.

    But sometimes, when I hit the corner of an object, even if it's square shaped, the character bounce diagonally. My question is if it's possible to use the bullet system but they can bounce only on 4 precise angles (I guess 0, 90, 180, and 270). Thank you!

  • 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

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