How do I get my player to be pushed when hit

Get help using Construct 2

Post » Thu Jan 29, 2015 12:19 am

Hey guys,

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

Anyway, my problem this time is:

Player Contact.png


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?
You do not have the required permissions to view the files attached to this post.
The moderators are corrupt and ban for no reason, especially that condescending neckbeard asshole Kyatric. The forums are filled with fanboys.
Banned User
B
22
S
7
G
1
Posts: 558
Reputation: 2,925

Post » Thu Jan 29, 2015 12:28 am

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 ...
Last edited by kossglobal on Thu Jan 29, 2015 12:31 am, edited 1 time in total.
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Post » Thu Jan 29, 2015 12:28 am

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. :)
move.png
You do not have the required permissions to view the files attached to this post.
Image Image Image
B
61
S
19
G
6
Posts: 325
Reputation: 7,944

Post » Thu Jan 29, 2015 12:29 am

kossglobal wrote:Btw, you don't need "Else" there.


That too!
Image Image Image
B
61
S
19
G
6
Posts: 325
Reputation: 7,944

Post » Thu Jan 29, 2015 12:33 am

Player.X < Enemy.X ---- Set player vector X to -500
Player.X > Enemy.X ---- Set player vector X to 500
B
60
S
10
G
10
Posts: 1,013
Reputation: 9,155

Post » Thu Jan 29, 2015 1:22 am

facecjf wrote: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. :)
move.png


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

Any chance you have anything else?
The moderators are corrupt and ban for no reason, especially that condescending neckbeard asshole Kyatric. The forums are filled with fanboys.
Banned User
B
22
S
7
G
1
Posts: 558
Reputation: 2,925

Post » Thu Jan 29, 2015 1:54 am

@Nesteris

Nesteris wrote: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.
move2.png
You do not have the required permissions to view the files attached to this post.
Last edited by facecjf on Thu Jan 29, 2015 1:59 am, edited 1 time in total.
Image Image Image
B
61
S
19
G
6
Posts: 325
Reputation: 7,944

Post » Thu Jan 29, 2015 1:58 am

@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!
Player Contact.png


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! :)
You do not have the required permissions to view the files attached to this post.
The moderators are corrupt and ban for no reason, especially that condescending neckbeard asshole Kyatric. The forums are filled with fanboys.
Banned User
B
22
S
7
G
1
Posts: 558
Reputation: 2,925

Post » Thu Jan 29, 2015 2:05 am

Glad you worked it out. :D
Image Image Image
B
61
S
19
G
6
Posts: 325
Reputation: 7,944

Post » Thu Jan 29, 2015 9:02 am

Great.
But i think you don't need the action : Set player speed to 0.
B
60
S
10
G
10
Posts: 1,013
Reputation: 9,155


Return to How do I....?

Who is online

Users browsing this forum: kellehk and 29 guests