# Thread: How do I change jump speed? - FastLoop Custom Platform Movement by DavidN

1. ## How do I change jump speed? - FastLoop Custom Platform Movement by DavidN

Hello again everyone.

I wanted to build my own platforming engine so I got started here:

http://www.clickteam.com/clickteam-blog?p=custom-platform-movement

Everything is going well, except I want to be able to change the speed of how fast the player moves in air when they jump and then fall.

As of now, the player moves up 1 pixel at a time, and moves down 1 pixel at a time:

On loop "Grav"
"Grav_" of (player) < 0:
- Set Y position of Player to Y of Player - 1

On loop "Grav"
"Grav_" of (player) > 0:
- Set Y position of Player to Y of Player + 1

The player moves up and down too fast, so I want make the player move up 0.5 pixels at a time, and move down 0.5 pixels at a time.

How would I go about doing this?

2. You could use an alterable value for the y position of the player. Then set the players y position to that value. You should also research into sub-pixel movement.

3. Danworth is correct. You need to reserve two of your alterable values and name them floatX and floatY. Instead of changing the object’s x and y position directly, you will be changing these alt vals and then setting the object position to the alt vals. This allows you to position things at decimal value positions. Fusion will automatically round the value to the whole number (since there is no such thing as a decimal position in screen coordinates) and position it properly.

4. Alright. I created a new test project and did exactly what you two said and managed to make an object move at a speed of 0.5 pixel every frame; perfect.

I tried implementing the exact same method to my game.

On loop "Grav"
Grav_ of (player) > 0:
- Set Y position of (player) to Y position of (player) + 1

I modified it to now be

On loop "Grav"
Grav_ of (player) > 0:
- Set floatY of (player) to floatY of (player) + 1

I modified every event that directly moves the position of the player so that it would now modify the Alterable Values for floatX of (player) and floatY of (player).

I'm currently only adding and subtracting (1) from the floatX of (player) and floatY of (player) just to see if I can replicate the physics as they were before I made the player's X and Y coordinates based off of the float values.

Unfortunately, this results in the player moving like this:
https://i.gyazo.com/0b4b1c73652d8f82...7cef54eafd.mp4

As you can see, it's not moving like it did before I made the player's based off of Alterable Values:
https://i.gyazo.com/0bc5e0c81ded7527...f5ca3e01f6.mp4

Any ideas as to why this is happening? I'm willing to give out the .mfa file if that will help diagnose the issue.

P.S. I made sure to set floatX to be the player's X coordinate and set floatY to be the player's Y coordinate, and made it always set the player's X position to floatX and the player's Y position to floatY.

Thanks for the responses

5. You'll need to set the position within the loop also. as within the loop will be faster than "always". so:

On loop "Grav"
Grav_ of (player) > 0:
- Set floatY of (player) to floatY of (player) + 1
- Set Y Position of player to floatY.

6. Also make sure you set your object's position initially as a float. I usually do it as "Set xFloat to X Position(active)*1.0" and "Set yFloat to Y Position(active)*1.0" This will initialize the objects with their correct starting position and also force Fusion to use float values. I tend to also add 1.0 instead of 1 to make sure floats are always being forced.

7. Okay so I just made the player's Y position get set to the floatY(player) during the "Grav" loop and did the same for the player's X position for the "Horiz" loop, and I added/subtracted 1 from the floatX and floatY value wherever the player object used to 1 added or subtracted from it's X or Y position.

This is working better, only now my player object is a bit jittery while moving across a backdrop or active and it is now able to phase through backdrops and active objects that it used to not be able to go through:
https://i.gyazo.com/bf6991f661221eef...9b1e782f44.mp4

Any ideas on how to fix this one?

8. Originally Posted by mobichan
Also make sure you set your object's position initially as a float. I usually do it as "Set xFloat to X Position(active)*1.0" and "Set yFloat to Y Position(active)*1.0" This will initialize the objects with their correct starting position and also force Fusion to use float values. I tend to also add 1.0 instead of 1 to make sure floats are always being forced.
Ah good idea.

I just implemented that now, thanks!

I believe it is using floats now, still of course have the strange jittering and phasing going on as mentioned about.

9. You need to detect for overlaps within the fastloop. If you detect on, then you need to change your float in the opposite manner that you did to move it. So if you added a value to move, you need to subtract the same value. Or vice versa. Then stop the loop.

10. Originally Posted by mobichan
You need to detect for overlaps within the fastloop. If you detect on, then you need to change your float in the opposite manner that you did to move it. So if you added a value to move, you need to subtract the same value. Or vice versa. Then stop the loop.
Okay thanks. I have it so if it detects the player is overlapping a backdrop, it will subtract 1 from their floatY value. Which is the opposite of adding one to the floatY value, which I have done for when the player is falling down.

I managed to fix the vertical jitter of the player while they're on a backdrop. Unfortunately, I changed one event and made a bunch of other changes that I undid so I can't remember how exactly I removed the vertical jittering. Now the only issues are the jittering still remains while on an active object (with the 'obstacle' qualifier) and I'm able to pass through any backdrop horizontally with ease: