I’m trying to make a move where the player rolls into a ball and basically can gain momentum loose momentum etc etc
FOR EXAMPLE
Normally when you press let’s say D key
You set player movement speed on X axis to 100
When you release D key you set player speed to 0
And that is how you make it move like you see in most games
Now instead of setting speed to 0 when key is released
You go with
Condition
INVERTED D key is pressed
Player speed is above 0
Action
Subtract 3 from player speed
And you are smoothly loosing speed but that is linear
You may want to go with
Subtract (Player.Speed()/90+2)
So more speed player have
Faster he will lose it so at beginning when you release D key it will start loosing speed fast but when he have little speed left he will lose speed slower
Kinda like actual ball would behave
Now imagine reversing that process for when D key is pressed
uh… what? I’m sorry but that confuzzles me
Are you using the platformer behavior on the player? Does the ball have physics?
If yes, then you can’t mix the platformer behavior with physics since both behaviors work in completely different ways and use different calculation methods.
You’ll have to recreate the character movements using physics forces to make this work. This will allow the ball to interact with the player realistically using physics and affect the speed of the player according to the forces, mass etc…
If no, then you’ll need to add more context so we can understand better what you’re trying to do.
Momentum is like only HOW you are decreasing increasing speed
IF yo want your player to roll at max speed of for example 120
Then you could add to player speed 1
And with each frame it would gain +1 speed unit
Imagine is as regenerating HP
You see HP bar fill with constant speed this method
BUT if you gonna fill HP bar with 1+(CurrentHP / 80)
Then more HP you have Faster HP bar will fill
So like car accelerating
You want to reach max speed of 200
But when you start your car you won’t start with 200 speed it will start from 0 and gradually will be moving faster and faster
Now question is
Do you want car to accelerate in constant rate
So like each sec it increase accelerating speed? or constantly gain same amount of speed?
For example
At sec 1 acceleration (NOT CURRENT SPEED) adds 10 to speed
But in 2 second acceleration adds 30 to speed
Where in 3 second it adds 50 or 70
And so go on
Where linear acceleration would be increase acceleration for 10 each second
So in 1st sec it would be 10 in 2nd it would be 20 in 3rd 30 and so go on
That is what i meant
You have 2 choices of how acceleration deceleration goes as i described above
SO aside from that
It is just constantly adding some value to other value
That is how you control speed i mean either you add to accelerate or subtract to decelerate
Sorry for replying to a dead post, I actually figured out a way to make ball mechanincs without using the physics behavior. This includes making the ball roll when its moving left and right, so this reply is basically how to make your own version of red ball lol.
When coming up with this method i came across a fatal flaw that is easily fixable via different copies of a sprite.
Step 1: Take your ball sprite and edit the collision mask to look like a circle. The more vertices you add to the collision mask, the smoother your movement will look.
Step 2: Add the platformer behavior and tweak as desired.
Step 3: Add a platform.
Step 4: Add a new event.
Condition, Keypress right arrow
Action, Rotate 180 degrees.
Step 5: For left movement.
Condition, Keypress left.
Action, Rotate -180 degrees.
Here we go over the most major bug i came acroos with this. (This was like the only bug lol.)
If you go over to a wall in game, the ball actually climbs up the wall. This is becasue the rotation action doesnt just rotate the image of your sprite, it rotates the entire object, including your collision mask. This is why you need to make a custom collision mask because with the default one youre quite literally rotating a square. So the big issue with the rotation is that, sqare or circle, the rotation somehow allows the collision mask to grab onto the wall and climb it. So to fix this you need to add 2 more events And 2 more sprites.
Copy your wall object twice and rename each to wall right or wall left. now you should have 3. one to act as a floor, and two for each side of a wall.
Now for the events.
Condition, Ball has collision with WallRight AND right key pressed
Action, Rotate Ball -180 degrees. (This is because with you pressing against the wall while moving, this event rotates the ball in the opposite direction, making it not rotate at all. Since the wallclimbing problem was because of the rotation, this fixes it.)
for moving left:
Condition, Ball touches Wall Left AND left key is pressed
Action, Rotate Ball 180 degrees.
I hope this helped. As of typing this im on a school chromebook, once i get to my computer i will provide a project file and demo on itch.io that you can use for reference ![]()