I am trying to simply character controller without using a rigidbody (since I don't need any physics.) The results are ok, but for some reason my gameObject moves faster when moving diagonally than when just heading in a single direction. Here is my code:
If anyone has any suggestions as to how I can get around this problem or perhaps even improve the above code, I'd really appreciate it!
asked Jun 20 '10 at 05:33 PM
Change the first three lines to this:
Since Input goes from -1 -> 1, you'll want to handle the case where x and y are both 1. The length of that is sqrt(2) if you do the trig. You want to just clamp it to 1.
answered Jun 20 '10 at 05:51 PM
Diagonally u mean when u press 2 keys like w + d in the same time? if yes, u can make a check and if it matches then to decrease the speed by 2.
answered Jun 20 '10 at 05:38 PM