Movement Engines

This guide will show you how to control a player’s speed. This is applicable in racing games and games where the player can have lots of speeds.

First, place a lot of speed modifiers. They will go from 1 to 4, in increments of .1. (1, 1.1, 1.2, 1.3, and on and on and on). Make the channel they receive on like this:

"Speed " + Number in the modifier

For the numbers without decimals, do not add the point 0. This format helps us use concatenation to set the speed. Now make a property called “Accel” and “Speed”. They should both be player scoped and numbers.

Make a lifecycle. It should listen for game start and broadcast on “Start Game Start”. Make a relay receiving on “Start Game Start” and broadcasting on “Game Start” to everyone.

To set a default acceleration and speed at the beginning, do this:

Default Speed and Acceleration

Use the defaults on the property if you want a whole number default. If you want a decimal default, continue.

Make a trigger that receives on “Game Start”. In the blocks, set your properties to the defaults.

Make a trigger receive on “Game Start”. Wire this to a wire repeater and back. The trigger should have a delay of .1s. This delay can change. A smaller delay is better, but it has a possibility of lagging out your game, the smaller you go. Now, in the blocks, set the speed property to itself plus the accel property.

Make the “Speed” property broadcast on “Set Speed”. Make a trigger receive on “Set Speed”. Enter this into the blocks:

image

My multiplication and division look weird because I wanted it to fit on the screen. You can replace the 3 with the highest speed you want. You can replace 1 with the lowest speed you want.

Now, you have something that can control a player’s speed! It’s time for the gas pedal and brake!

Make two overlays, both buttons. One should say Brake and one should say Accelerate. They should broadcast on “Brake” and “Accelerate”. Make two player scoped number properties. One should be called “BrakeFactor” and one should be called “AccelFactor”. In the blocks for the braking overlay, make the block receive on “Brake” and set the acceleration to “BrakeFactor”. Do the same thing for the acceleration overlay but with the acceleration names.

This system makes it so that pressing the button takes you either the top or the bottom limit. If you want more Make a trigger that receives on “Brake”. Wire it to another trigger that receives on “Accelerate”. This trigger should have a delay higher than the delay for the trigger from the start setting the speed to itself plus one. In the blocks for the trigger receiving on “Accelerate”, make it set “Accel” to 0.

You can change the accel factor and brake factor constants in the defaults trigger in the optional section. Now, you just need to calibrate the numbers how you want.

Can someone give some delays and numbers that work pretty well for them?

Difficulty
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
0 voters
15 Likes

Wow! Nice guide!

1 Like

Thanks!

3 Likes

Perfect. :ok_hand:

1 Like

Um the poll doesn’t have a max amount of answers

I rated it 8 cuz for beginners, not to be rude.

Nice guide!

1 Like

I thought I put 1…

1 Like

Good.

Wow! That’s a good use of the create text block

1 Like

@getrithekd What is the property “Velocity”? Also BUUMP!!!

2 Likes

Oh whoops. You need a player scoped number property for that.

1 Like

bump for goodness

5 Likes

Bump
Couldn’t you use the player coordinates device to do this now? Like track that the x/y properties are changing at the lowest constant speed rate and above and players gain more velocity the longer they stay at the lowest constant speed rate via speed modifiers? then they restart when they bump into a wall or slow down or something…
ik getrithekd/you can’t edit this anymore but this is just an idea.

1 Like

This is supposed to set the velocity, not measure it, so the player coordinates device is not applicable to this.

2 Likes

Nice!

@Cookie_Simulator are you a real bot?

What do you think? :wink:

9 Likes

Welcome to the forums @Cookie_Simulator
Look forward to your participation here on these forums!

Welcome to the forums @Cookie_Simulator !
wait a minute…

1 Like