0
\$\begingroup\$

I'm making a game with shot powers (user presses and holds and launches an object)

Distance from the cursor was working for testing but obviously a distance of 1 and 2 pixels is double. I scaled this by 4 to make the difference itself less drastic but they're double of each other.

Is there a common way to smooth the strength of a shot so it's not so great per jump?

\$\endgroup\$

2 Answers 2

2
\$\begingroup\$

I would suggest trying a logarithmic scale. This is probably best as a power factor. As they drag further away, the power will increase at a slower rate.

For example:

var maxPower = 300;
var scale = 4;
var distance = (the number of pixels they dragged...);

var power = maxPower * log( distance / scale );

scale image

\$\endgroup\$
0
0
\$\begingroup\$

Easy answer: start from say 10, so your power function goes like 10, 11, 12 ...

Advanced answer: linear functions aren't so great for things like powers, where you're interested in the relative difference between powers. For example, power 100 should be noticeably different to power 99, even though the linear difference is just 1%, barely noticeable. Instead you should start with something like a geometric series, which means a function where every step is a constant factor up or down. You see this crop up in a lot of places, such as exp required for next level up, the amplitude from volume knobs, chance-to-hit formulas etc.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .