I have downloaded lots of platform examples and read lots of articles but can't still find answers for these problems. Maybe they are just too easy ones or then I'm just too noob =I
1. How can I make a "box" like in Super Mario (You can get mushroom to come by hitting the box with your head from down but nothing happens if you try it from up, left or right)?
2. How can I make enemies like in Super Mario (again) (You can kill them by hitting with your legs from up but if you try to hit from left, right or down, it kills you)
Thanks if you're kind enough to answer! And sorry my bad english =(
Create a object that looks like a horizontal line ("head line") with the size of the head, and another one with a bit less than the size of the legs ("leg line"). The programming is simple...
Always - Set position of "head line" to top of "character" AND Set position of "leg line" to below character
If "head line" collides with "box" - Create "mushroom" at "box" AND Destroy "box"
If "leg line" collides with "enemy" - Destroy "enemy"
If "enemy" collides with player - Destroy player and remove 1 life...
Thanks a lot = I'll try it... and if it doesn't work I try it over and over again. I'm really thankful and happy that there is still kind people in internet.
That wouldnt quite work, you could be traveling in any direction and still that could colide with it.... you could do a jump over the enemy and still hit the enemy with the line at the base of your player.
Perhaps try adding another condition in saying if direction is dowm, or if direction is up in the case of the mario style box.
Santa : That won't work as it will not detect if you're falling (down + left/right). And, about what you said, that's why I told him to make the bar a little smaller than the legs.
or in general we say, you know how to fix problems.
And i am sure i would have something suggested like:
while you're character in the air is jumping and his direction is up then something can pop up from the box.
and the opposite for the leggy thing,
falling instead of jumping and down instead of up.
If you've a custom movement, it's very easy to implement
this speudo code
(which means: it's telling what kind of code you need
and it's up to to you to write the code).
Or wait a minute... are you sure that the tip works? I mean if you do so doesn't it make the mushroom come out from the box even though you hit it from left or right (You are on air and your direction is up).
Thinking about what Jenswa said : Do you have a Custom Movement Engine? If not, then this method isn't good. And, how many times should I say, FALLING is not down, its down + left/right and JUMPING is not up, its up + left/right, so you must put many directions in it and it will turn into a pain, you will get crazy, get a pistol and shot your head fifty seven times. Got it?
oh! and the only tip that works in this post is rpg player 2003's (but you should detect if the player is falling while the detector collides with the enemy)
Beware of life ...so far noone have survived it.......