fredag 12 juni 2015

Arduino to Unity Project Part 10: Adjusting controls


To get a smoother and better control I did two adjustments


Movement/Rotation Speed
I removed the normalization of the direction vectors used for movement/rotation. That way, the vector is bigger/small depending on how far you push the thumbstick in some direction. This means that if you just push the thumbstick a little bit you will for example rotate very slowly but if you push it harder the rotation will be faster. This enables the player to do both high-precision and fast turning/moving input.

Deadzone
One thing I have not described is the deadzone. On a analog controller that can be moved along the X and Y axises, the analog stick should in its initial state (not pushed) be at origo. In my case each thumbstick is in the origo of a coordinate system which goes from -510 to 510 on both axises. So in the inital state, the value of the thumbstick potentiometer should be 0,0. But since its analog and has it is not exactly at 0,0. It might be -20 or +30 off. This position can be detected and understod by my script as a direction vector and will cause unwanted movement/rotation. To avoid this, I created a deadzone, meaning that if a value from the potentiometer is in the range of: -35  < val < 35 it is interpreted to 0.

Today I read a very interesting article/blog about how to program deadzones. It is written about a professional game develop and seems legit. Very interesting, you can read it here:
http://www.gamasutra.com/blogs/JoshSutphin/20130416/190541/Doing_Thumbstick_Dead_Zones_Right.php

I learned from this article that a better deadzone is implemented by using the magnitude of the vector insted of just the vector x and y values. I changed my script to a solution based on this implementation and the result was somewhat smoother.

Inga kommentarer:

Skicka en kommentar