Posted By
|
Message
|
Disthron
Registered 08/02/2005
Points 1101
|
11th June, 2009 at 16:56:19 -
Hi every one.
A little while ago I released a little platform engine witch I'm still working on. The moving platforms are still giving me trouble. The Platform Movement Object has 2 variables in it that are "Additional X Velocity" and "Additional Y Velocity". I believe that these are used for things like Moving platforms, conveyor belts and wind/water motion.
They add to the velocity of the player. Like if the player is on a moving platform and is pressing the joystick left then they are moving at the speed of the platform + the speed of the player.
My problem right now is that I can't seem to figure out what the X or Y velocity is. I mean the speed is easy enough but I have never had to know this before. I have tryed looking through the threads and articles and was unsuccessful. So I was wondering if any one out there knew how to find out an objects X and Y velocity/speed?
I think it would really clean up the code if I could figure out how to use this properly. It would probably iron out some of the bugs as well. Anyway, even if you don't have the answer thanks for taking the time to read over my thread.
"Oh, my god! A lightning monster just ripped out this poor woman's eyes, and your mocking her shrubbery!" - The Spoony One
|
Disthron
Registered 08/02/2005
Points 1101
|
11th June, 2009 at 16:58:20 -
DAm! I forgot to ask this, some one was kind enough to post there Bionic-Commando style grapple and rope system the other day but I can't seem to find it agen. I would like to give it a try.
"Oh, my god! A lightning monster just ripped out this poor woman's eyes, and your mocking her shrubbery!" - The Spoony One
|
Zephni My other cars a Balrog
Registered 17/10/2007
Points 4019
|
11th June, 2009 at 17:09:41 -
maybe im looking at this wrong... but by the looks of things your not moveing the platforms right in the first place, because the platforms should be moveing by them variables anyway... therefor THAT is the speed you need to add to your player.
lets say:
always set position of moving platform to moveing platform + "additional x"
then say when that platform colisions with a detector/backdrop, set its additional x to the oposite direction. OR just say if addition x is greater then add that value to the mocing platforms position. And if it is less then minus that value from its position.
Then all you have to do is set your players x value to that value and its all good!
remember when useing loops colision detectors and positions must be sated on each one.
dont make me divide by zero...
|
OMC What a goofball
Registered 21/05/2007
Points 3516
|
11th June, 2009 at 17:10:26 -
To get the X and Y velocities, you can always set a counter or alterable value to it. EDIT: Maybe I misread that. Do you want the X and Y velocity of the PMO object or the platform? O_o Because you make the platform movement yourself and should be able to get the X and Y speeds.
Also make sure you check out the moving platform example in the PMO help file.
Edited by OMC
|
Disthron
Registered 08/02/2005
Points 1101
|
11th June, 2009 at 17:40:31 -
The additional velocity variable only effects the player. It has no effect on the moving platforms. So I am trying to find out the platforms speed along the X and/or Y axes. I move the platforms with a simple "add 1 to X position of platform". However, if I could figure out how to do this I could use a bouncing ball or some other movement instead.
If I give the platform a movement, like bouncing ball, then there is the speed variable but that dose not differentiate between X or Y. If it is movie left and then switches direction to up the speed will stay the same. However the X and Y velocity should change baced on the object's direction. If it's going up, the velocity of the Y will change, if it's going across then the X will change.
Edited by Disthron
"Oh, my god! A lightning monster just ripped out this poor woman's eyes, and your mocking her shrubbery!" - The Spoony One
|
OMC What a goofball
Registered 21/05/2007
Points 3516
|
11th June, 2009 at 17:55:18 -
I'm almost certain there was an extension to retrieve the speed of an object, (hopefully in separate X and Y form) but I can't seem to find it. You could still do a movement.
Object direction is left >>> X velocity is -speed
Object direction is right >>> X velocity is speed
Object direction is up >>> Y velocity is -speed
Object direction is down >>> Y velocity is speed
Object direction is diagonal >>> Maths. I can't seem to remember how to get X and Y velocities from a vector, hopefully someone else can. For some reason I'm thinking the Pythagorean theorem.
I've used counters before to keep track of the speed of something. Always set the counter to the new X position minus the old counter value.
Edited by OMC
|
UrbanMonk BRING BACK MITCH
Registered 07/07/2008
Points 49667
|
12th June, 2009 at 02:19:38 -
Record the x and y position of the plaforms into their own alterable value.
Do this after you want to get their x and y speed.
Then to retrieve their speed do-
oldx-currentx=x speed
oldy-currenty=y speed
Again make sure you record the old x and the old y after you have used them because mmf calculates their movements after the main loop is done. Therefore, if you grab the x and y of any object using the default movements right before the end of the loop those numbers will be "old" when you reach the top of the loop again because mmf would have repositioned them already.
Example here-
http://www.jsoftgames.com/speedcheckexample.zip
n/a
|
OMC What a goofball
Registered 21/05/2007
Points 3516
|
12th June, 2009 at 03:06:13 -
Originally Posted by OldManClaytonI've used counters before to keep track of the speed of something. Always set the counter to the new X position minus the old counter value.
|
nim
Registered 17/05/2002
Points 7234
|
12th June, 2009 at 05:45:34 -
Quick reference for MMF speeds:
Speed 80 = 10 pixels per frame
Speed 100 = 12.5 pixels per frame
//
|
Disthron
Registered 08/02/2005
Points 1101
|
13th June, 2009 at 10:56:27 -
So, UrbanMonk, I should use fast loops to determine the speed on the individual axes (X,Y)? And... I should set the "old position" at the start of the fast loop and then calculate it at the end? Or is it the other way around?
"Oh, my god! A lightning monster just ripped out this poor woman's eyes, and your mocking her shrubbery!" - The Spoony One
|
UrbanMonk BRING BACK MITCH
Registered 07/07/2008
Points 49667
|
13th June, 2009 at 23:47:43 -
No fast loops are necessary. MMF will apply the appropriate values to each object individually because of something in MMF called object scope.
This is just sudo code, but you should get the idea
----When Floor Detector Overlaps "moving platform"
-set additional x velocity to - (X Position of "moving platform")-(Alterable Value A of "moving platform")
-set additional y velocity to - (Y Position of "moving platform")-(Alterable Value B of "moving platform")
Add this to the end of the event list-
----Always
-set Alterable Value A of "moving platform" to X Position of "moving platform"
-set Alterable Value B of "moving platform" to Y Position of "moving platform"
Now of course this is just an example.
Apply it wherever you need it.
You should be able to use any type of movement on the moving platform just as long as it's movement calculations are done after recording the oldx and oldy positions.
A "Moving Platform" Group could also be used and is encouraged as it allows you to reuse this code whenever you need it.
If you need anymore help I'll make an example file for you when I get a chance.
EDIT: here is an example of all this knowledge applied. I used the default platform movement for this example, so default platform movement problems still exist (getting stuck in walls ect.) But it should still give you the basic idea. http://www.jsoftgames.com/platformexample.zip
Edited by UrbanMonk
n/a
|
Disthron
Registered 08/02/2005
Points 1101
|
14th June, 2009 at 13:20:50 -
Hi UrbanMonk
Thanks for your example, I hope I'll be able to use that idea in my engine. A better functioning moving platform system is really needed for this little demo I'm working on.
It's a bit late now so I'll have to try it later. I'll let you know how it tunes out.
"Oh, my god! A lightning monster just ripped out this poor woman's eyes, and your mocking her shrubbery!" - The Spoony One
|
UrbanMonk BRING BACK MITCH
Registered 07/07/2008
Points 49667
|
14th June, 2009 at 15:32:21 -
Yes, sorry I didn't make a custom engine for it, but I was trying to get it done quickly.
Make sure to replace the bit about the player object overlapping with your floor detector instead.
n/a
|
Disthron
Registered 08/02/2005
Points 1101
|
18th June, 2009 at 17:44:51 -
Wow, that actually works pretty well. though I still have not managed to get the hang of this additional x and y velocity thing. I tinkered with it a bit and got it working to a certain extent. If I made the path go along the X only it worked fine but any movement along the y and the player would fall through.
Then I tried just implanting your code to move the player and it worked pretty well. Although it's still quite glitch. Can I ask in this code
Y( "Platform Man!" )+(Y( "Group.Good" )-Alterable Value B( "Group.Good" ))-(Y( "Platform Man!" )-Alterable Value A( "Platform Man!" ))
What is the second part for? Where you subtract the platform man y position and alt ver A.
I'm still trying to get the additional speed thing to work, as the player will still react to obsticals properly if I can get it to work. You know how in some games you'll be on a moving platform and there will be a block that the platform gose under and you have to jump or you will fall off. Using your code (and my old code as well) if you try that in a level the player will just get stuck in the obstacle. Just like in the standard platform movement. Also, it should be smoother movement that way.
If you'd like to check out what I've done so fare I uploaded it to file front. I've been integrating it into the second frame of the program. The first is the original release and the third is my atempt at mode 7. I have to worn you though it's pretty messy.
http://files.filefront.com/HE+Application+14dzip/;13912088;/fileinfo.html
"Oh, my god! A lightning monster just ripped out this poor woman's eyes, and your mocking her shrubbery!" - The Spoony One
|
UrbanMonk BRING BACK MITCH
Registered 07/07/2008
Points 49667
|
21st June, 2009 at 02:01:36 -
Sorry I haven't been around to help you out. I'm not at my house right now. I won't be for another week, so after next week I'll help you out. I hope you can figure something out by then!
n/a
|
|
|