Hey guys I’m making a 2 player platformer game and I want people to sabotage so I want them to be able to push each other and jump on top of each other. But I can’t get the code to work. Does anyone know how to code it
I think solution to this was to give each player at the same time platformer character behavior and platform object behavior
Hi. It does work but I want them to be able to push each other. Do you know how to do that.
Well think for a moment cause you need to consider few things
Like what if they stand next to each other and push themselves opposite directions?
I would say then it would assume then you would want them NOT to change position since forces should negate themselves
Where if ObjectA is on the left and is pushing ObjectB to the right
Then ObjectB should be pushed to the right
I would assume something like
Condition
ObjectA is in collision with ObjectB
ObjectA X position is less than ObjectB X position (so A is left from B)
ObjectA is holding Right
INVERTED ObjectB is holding Left
Action
Change ObjectB X position add1
And that is just for pushing object B right by A
You would now need to prepare vice versa scenario when ObjectB pushes A to the right if B is on the left
Then you need 2 more events for each one pushing other to the left if they are on the right
Hi there.I tried that but it didn’t work my code says that the imp can push the tiny zombie left but it doesn’t work do you know what’s wrong
Where does it says that?
Cause as i see this will allow you to push tiny zombie right if imp is on the left
Also i tested it
And giving platform behavior to them is bad
So remove platform behavior from them if you added it
And instead of add 1 to tiny zombie X pos add 2
I see it gives much better result
Hi there. It does work but now if the imp and the tiny zombie run at each other they just run past each other. Do you know how to fix that
I have shown you how to do it for one case scenario
Now you need to create events for other case scenarios
So looking at your events
This is for imp pushing zombie to the right if imp is on the left
So now to push imp to the right if zombie is on the left
Again referring to your events from screenshot
Conditon
Imp is in collision with zombie (here order does not matter)
The X position of Zombie is less than Imp.X()
Zombie has the Right key pressed or simulated
INVERTED Imp has the left key pressed or simulated
Action
Change X position of Imp add 1
And now you need another 2 events for each of them pushing left other one
So i gonna write down one for zombie pushing imp to the left
And you should be able to do that adapt that for imp pushing zombie to the left
Conditon
Imp is in collision with zombie
The X position of Zombie is GRATER than Imp.X()
Zombie has the LEFT key pressed or simulated
INVERTED Imp has the RIGHT key pressed or simulated
Action
Change X position of Imp SUBTRACT 1