How do I use alterable value to make an object jump when it hits a detector?... If at all possible, please include jumping straight up into the air, and also an example on making the object jump to the left and/or right. I cannot even begin to describe how helpful this board and its members have already been to my learning experiences in MMF2... Thanks again guys.
If it matters, I'm wanting to know for a specific enemy's movement, not my player.
n/a
Deleted User
9th April, 2008 at 10:41:25 -
Do you currently have any movement for the enemy? If you're using a default movement like the path movement, that could make it hard.
For movement with Alt values, it could be as simple as Always setting the X and Y values to "X + Alt Value A" and "Y + Alt Value B" respectively. Then you'd have to put in some gravity by making it so that when the object is not over a background, the Alt Value B is continuously added to. That way when you hit Jump or collide with something, you change Value B to, say, -15. The effect will be a rudimentary jumping. To jump sideways, do the same with Value B but then make it so that Value A (the X variable) changes accordingly, either negative or positive depending in which direction you want to jump.
Guru, that sounds pretty close to what I'm looking for... could you put that in code format so I could understand how to implement it a bit easier... I'm so nub to mmf2 that it's difficult for me to understand unless it's laid out in stone... gonna start trying to understand what you've put in here....
btw... enemy is set to static movement... not path.
Okay...I'll assume that you're talking about a platform object that you want to jump when it hits a detector (like maybe a rock that's in its path):
Always --> Set X Pos "object" to X Pos + Alt Value A of "object
Always --> Set Y Pos "object" to Y Pos + Alt Value B of "object"
NEGATE: "Object" is overlapping background (obstacle) --> Add 1 to Alt Value B (change "1" to something else if you want stronger or weaker gravity)
"Object" collides with bacground --> Set Alt Value B to 0 (zero)
"Object" collides with "Detector" --> Set Alt Value B to -15
Unless I'm forgetting something, that should take care of up and down jumping.
To give the character a boost to the left or right so that he doesn't just jump up and down stupidly, you need to do something similar for the X position.
"Object" collides with "Detector" --> Set Alt Value A to -15
"Object collides with background --> Set Alt Value A to 0 (zero)
This will make it so that upon colliding with the detector, your object with fly to the left at a constant speed until hitting the background again. If you wanted to use Alt Values for left to right movement, you don't have to make Alt Value A change to zero when colliding with the background, so that he'll keep going.
To make him jump to the right, just make Alt Value A change to positive 15 instead of negative.
That's about it, and from there you can get more complicated, using multiple Values to simulate acceleration and such. Good luck!
Hmm... I must be applying this wrong... I tried it, but all it does when i hit the detector is cause the enemy to spasm uncontrollably and limit the movement....
I'm not exactly wanting the enemy to hop over specific objects so much as I am wanting him to simply hop from detector to detector... and, upon hitting a left/right detector, change directions..... Think of it like a path movement, but with hopping and more versatility to change.... I think you're very close to what I'm looking for.. the most I was able to accomplish myself is an enemy that hops once and then vanishes?.... thanks for the input and ill be awaiting another response
Do you think you could upload a bitmap or oekaki thingy that illustrates what you mean? I'm having a difficult time imagining it...I have to go to class though, so I'll check back tonight...
the drawing above illustrates what I'm looking for... basically, when the enemy is visible on the screen, move detector 1 to his position to start the loop... If at all possible, I would love for the enemy to simply jump back and forth between detector 1 and 2, and, every 10 seconds or so, make him hope to detector 3 before returning to detector 1 and restarting the cycle....
Technically, I guess I could this with path movement, but I've tried it, and it looks horribly sketchy.
The example enemy AI you posted is not quite what I am looking for.... Think more of a boss-fight situation... like the old megaman games, they perform specific loops that basically just repeat.
I see what you mean now...you can do this with Alt Values, but honestly, I essentially gave up on math when I finished it high school (four years ago). I think that you'd have to use parabolic functions or something to help the object figure out what Alt Values to use in order to get to a pre-ordained spot. Quite frankly, it might just be easier to test a bunch of different values (still using the system I posted from before) and change them until the boss lands where you want.
This may seem cheap, but infinitely easier (at least for me).
I suppose, though, that you wouldn't be able to get him to make it right back to the EXACT starting point, and then you might have to program in a little sneaky repositioning.
You should be able to get the effect you want by strategically placing the detectors, making sure they're the right type and setting the bounce values to specific values that will make the jump land where you want. I'd explain more, but I'm afraid my account will be deleted before I'm able to write a lot out.
Was going to submit it as a download, but I suppose that won't be happening if the admins are going to be completely unfair and go back on their word.
Wow.. that is amazing... It works like a charm! Thanks so much!
WOW... another weird problem... it works perfectly when i open it straight from the .rar... but when i extract all the files into a directory, open the file, it all looks the same.... press run application.. the red squares (enemies) just fall off the screen.... does the same thing in graphical mode and when i create the enemies.... odd.