7 – Finetuning Core Movement

Slippery Character Movement & Wall Collisions

If you noticed and compare the first video and the recent ones you’ll realise that I tweaked and iterated the movement mechanics of the character a bit.
As you can see in the first video Gameplay Prototyping 1 – Movement the player slides about whereas in the third video the player doesn’t anymore.

This was essentially an oversight caused by application of PhysicsMaterials as to make the player slide down the wall when colliding (and not get stuck!) the platforms needed 0 friction but this meant the player would also slide along the surface.

This would also have been a major problem when I integrate mobile ’tilt’ controls using the phone’s accelerometer, this is due to the fact that if the player slides around even if no input is being made it would require the player to tilt their phone to counteract the natural slide at all times – making the game very hard to control and frustrating.

The game itself will already be hard enough to control with the tilt so we need as little-to-no input lag as possible: if the player moves right they move right, if the player stops moving right they stop right then and there.

 
Picture

 
The first issue was to prevent sliding which I fixed by adding a PhysicsMaterial with a friction of 1 on the Player GameObject.
 
Picture

 
The above fixed the sliding issue but the player would still get “stuck” on the wall if they constantly move into it (which you would if we had the accelerometer tilt controls).

After researching I found that there was any way to restrict PhysicsMaterials to a certain side/face of the object, via Unity’s Platform Effector 2D Component, with that in place for all objects the core principles and movement mechanics of the game was sorted.

 

No-limits Movement Speed

As the initial movement code was barebones if the player simply held down the Left/Right key they would increase speed and travel to near-lightspeed.
Picture

 
Thus I created some limiters to the speed in the playerScript, hopefully since its tied to a variable I can link it to a possible future Power-Up, for example something akin to ‘Running Shoes’ from Pokemon.

Leave a Reply

Your email address will not be published. Required fields are marked *

I accept that my given data and my IP address is sent to a server in the USA only for the purpose of spam prevention through the Akismet program.More information on Akismet and GDPR.