Fangames > Programming Questions
"Pushing" the player?
(1/1)
128-Up:
I'm using Lemon Engine and trying to create something so that an object pushes the Kid while he's touching it. (Basically a conveyor, but also applied to the air.) I think late rooms in Challenge 100 Trials used this kind of mechanic.
I noticed that it works perfectly... so long as the Kid's not touching the ground. Trying to remedy this with making a conveyor block still doesn't affect the Kid. What's causing the blocks to make the player unaffected by the pushing object?
Derf:
I also use Lemon Engine, I'm very fond of it.
I just created a conveyor belt block in my game to test this and it works fine. Here's the code:
--- Code: ---if(collision_rectangle(x,y,x+32,y-128,player,1,0)) {
player.hspeed += 0.75;
}
--- End code ---
If you put that in a block object's step event it will function as a conveyor belt when you're on it and also when you're within 128 pixels above it.
If I misinterpreted what you wanted and you just wanted two separate objects, one that is an block that accelerated you when touching it and another that you pass through in the air but that also accelerates you. Then you put "player.hspeed += 0.75;" or whatever acceleration you want in a collision event of both a solid block parented object and a pass-through object.
128-Up:
That works but it seems like the effect is doubled if the player's touching two of the objects at once, and I'm not sure how to make it so that even if it's touching multiple pushing objects the strength is the same as if only one was touched.
Derf:
Hmm.
Could always take the collisions out of the objects and put them in a controller object that checks if the player is colliding with any of them and applies the code itself which will therefore only be once?
YoSniper:
Try this:
In the player's Step Event, include this piece of code, or similar:
--- Code: ---if collision_line(x, y, x, y + 32, objConveyorBlock, true, true) {
hspeed += 0.75;
}
--- End code ---
You would have to distinguish between left and right conveyors eventually, but this should be a start. Also note that the player's hspeed gets reset at the beginning of each step, so you need not worry about the player accelerating to the right.
Navigation
[0] Message Index
Go to full version