Closed msbit closed 3 years ago
yep +1. I figure that controller code might get re-written when introducing game pad support which I'm keen to do sooner rather than later.
Yep makes sense.
What I've seen in simple game engines is to have:
acceleration
damping
velocity
position
and on each engine update:
acceleration
acceleration
acceleration
to velocity
damping
to velocity
velocity
between valid valuesvelocity
to position
I've put together a quick example here.
Check out
https://github.com/stewartmatheson/projectx/commit/fafa4331d7f78efeb1f2a32a51eb97d754f2a8c5
Working a lot better now. Still does not feel quite right but the system is much more solid. Based on your example code which was a huge help :D. Have not done the clamping yet though.
Looks good!
When calculating the player velocity, per update, we have:
https://github.com/stewartmatheson/projectx/blob/b47569d61c16974b0863a612623fdbd999ef722d/src/PlayerController.cpp#L49-L52
which causes the speed (for a given vector) when going from stop, to movement, then back to stop, to be something like this:
In combination with:
https://github.com/stewartmatheson/projectx/blob/b47569d61c16974b0863a612623fdbd999ef722d/src/Entity.cpp#L26-L32
it causes the
Entity
'sfacing_left
to flip-flop each frame until it settles back to 0, which is visible when drawing.Is it worth going back to something simpler like:
?