Im still a noob and i was wondering whether any of you guys know how to change the direction of gravity in MMF2. Im making a side scroller/platformer, i want it so my character can walk on walls.
Alternatively, you cando it quicker with 2 gravity variables:
* Add (Speed * XGrav) to X Velocity("Player")
* Add (Speed * YGrav) to Y Velocity("Player") (bearing in mind (0,0) is the top left, therefore, if you add 1 pixel you go down the screen)
The speed is the number of pixels/frame you want to move. I.E if 2, you will move 2 pixels for each frame.
*Some events that flip Gravity*
- Set Xgrav to +/- 1
- Set YGrav to +/- 1
If +1 the gravities will be the same, if -1 the gravities can be reveresed.
Alternatively you can randomly increase the size of gravity by changing the 1 to 2, 3, etc.
- Player: Set X position to X("Player") + X velocity("Player")
- Player: Set Y position to Y("Player") + Y velocity("Player")
ok...I'm one confused noob....
Can you please explain it to me by like telling me what events then the result?
And when you say velocity, i cant find it, do you mean speed? Then X Gravity "player", i can only change the Gravity, not X gravity or Y gravity.
Uh, first you better learn about fastloop engines. Just, now, for your own good, click on your player, go to the movement tab, and with a bold and meaningful click, select "Static" as the movement type. Then, search "Fastloop engine" and you'll probably be able to find a good engine.
hahaha just found out that i've been creating my own custom movement engine from scratch when i could have used a generic platform engine, guess i'll just finish my engine... Then i found out what alterable values are, everything is so clear now!
Thanks for the help and thanks for not flaming on me on being such a stupid noob.
"hahaha just found out that i've been creating my own custom movement engine from scratch when i could have used a generic platform engine, guess i'll just finish my engine... Then i found out what alterable values are, everything is so clear now!"
I strongly advise against that. There are so many ways to make a custom movement engine, that if you finish your engine, and try to figure out variables and fastloops afterwards, you might just have to rewrite your entire engine. It'd be a good idea to do it right, from the start.
X velocity and Y velocity are not attributes like the speed or acceleration things that you find under the active object's movement submenu in the event editor. X velocity and Y velocity would be variables, which practically means they're counters, or more specifically alterable values. In case you don't know what alterable values are; They are like normal counters, they are used to store numbers. Each active object has a number of alterable values (3 in TGF, 25 in MMF and unlimited in MMF2). The variables I named X velocity and Y velocity would be used to store the current X (horizontal) and Y (vertical) speed of the object. So they'd provide pretty much the same function as the speed attribute, except it'd give you more control of the movement.
So, to move your player, you add the value of X velocity to the player's X position, and the value of Y velocity to the player's Y position. It's not that hard to understand, really. So, after that, you can manipulate the player's speed freely, just using those two variables. So, to apply gravity to the object, you'd obviously add/subtract from either X velocity or Y velocity, to accelerate the player in any particular direction.
So, to get the directional gravity effect, you could do like Joe said, and add two more variables to the object; X gravity and Y gravity. Then, just always add the value of X gravity to X velocity and Y gravity to Y velocity. After that, you can manipulate the gravity easily, just by changing the value of X gravity or Y gravity. For example, setting X gravity to -1 would make the player fall to the left, while setting Y gravity to -1 would make him fall upwards, and Y gravity to 1 would give you normal gravity.
Circy's idea, to use groups and activate/deactivate them depending on the gravity, would maybe seem easier to code, but in the end, you'd only end up with four times the amount of code, for the same effect.
Also, try DC searching for "Custom movement engine". I don't know where Bibin got the term "fastloop engine", because it really doesn't have much to do with directional gravity or custom platform movement engines.
"I strongly advise against that. There are so many ways to make a custom movement engine, that if you finish your engine, and try to figure out variables and fastloops afterwards, you might just have to rewrite your entire engine. It'd be a good idea to do it right, from the start."
Starting over won't be a problems since i have like 2 events that acutally work how i want it.