How do I get my player to be pushed when hit

0 favourites
  • 10 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • Hey guys,

    It's me! The bad AI programmer and total development noob

    Anyway, my problem this time is:

    [attachment=0:3rgcr35b][/attachment:3rgcr35b]

    It doesn't work how I imagined, which was "On player collision, player is pushed back".

    Basically I tried to make it so that, if the player was facing or moving right, he'd get pushed to the left and vice versa.

    However, what happens instead is that he stops, turns around and then runs in the direction in the events and then stops.

    What I wanted to happen was that he gets pushed back immediately and doesn't not turn around.

    Anyone know how to do this?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Only setting vector X or Y should have this effect of being pushed. It's straight foward. Perhaps some other of your events are messing up these actions I guess.

    Btw, you don't need "Else" there.

    Edit: I think I know what is happening. You setting the maximum speed to 0 and after the vector X action, you are setting the maximum speed again. It means that, at the moment you set the vector X, his maximum speed is 0 so he won't move at this very moment. Try in this order:

    set maximum speed to 0

    se maximum speed to ....

    set vector X to ...

  • When I need to move or push a player with platform behavior, I don't touch the platform behavior vectors. It tends to get weird and not act as expected.

    Here is a screen shot of how I handle my character bounce back. Move by pixels at angle.

    [attachment=0:3glku6yi][/attachment:3glku6yi]

  • Btw, you don't need "Else" there.

    That too!

  • Player.X < Enemy.X ---- Set player vector X to -500

    Player.X > Enemy.X ---- Set player vector X to 500

  • When I need to move or push a player with platform behavior, I don't touch the platform behavior vectors. It tends to get weird and not act as expected.

    Here is a screen shot of how I handle my character bounce back. Move by pixels at angle.

    [attachment=0:2cwj3dm2][/attachment:2cwj3dm2]

    Just tried that, the player teleports to the destination instead of getting pushed/shoved back.

    Any chance you have anything else?

  • Nesteris

    Just tried that, the player teleports to the destination instead of getting pushed/shoved back. Any chance you have anything else?

    Try this instead for a more fluid movement. It sets platform vector X instead of move.

    [attachment=0:1mwko2ns][/attachment:1mwko2ns]

  • A0Nasser

    That gave me the exact same results that my events give.

    kossglobal

    That gave me the exact same results that my events give.

    If I follow facecjf then my player teleports. (EDIT: Was talking about your first suggestion.)

    Double EDIT: Just tried it, same result as the others and my first try. Look at suggestion below!

    If I follow your two, I get the same result I got with my events in the screencap.

    Update: I found a solution!

    [attachment=0:40wv42te][/attachment:40wv42te]

    The solution was to add a wait action for 0.100s because that's how long it takes for the first X Vector push to take effect and move the player, then the second one activates when it ends and gives it an extra push. It works great and even if you keep the button to move against it down, there's about a 0.250s delay before he starts moving due to the button, because the X Vector push still affects the player.

    Thank you all for the help, I wouldn't have come up with the idea if not for you guys!

  • Glad you worked it out.

  • Great.

    But i think you don't need the action : Set player speed to 0.

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