Skip to main content
GameDev.net gamedev.net
🔒 Locked 🎮 Unity

Unity - How do i clamp the speed of my character controller

Started by SrEdgar Mar 26, 2020 at 3:19 PM 3 replies 5.9k views
Original Post
SrEdgar
SrEdgar

Hi everyone, im having a problem with my character controller speed

When i press both axis the speed increment, i dont understand why. Do you know a way for clamping my vector3 move?…

Alberth
Alberth

You should probably find out why, and fix the problem rather than work around the problem.

Did you try debugging? When you dump those values to the screen do they make sense?

I assume you already considered that both x and z have value ‘walkspeed’ when used, so in total, you're moving sqrt(2)*walkspeed. (Instead of 3d think 2d, moving 1 in either x or y has length 1. moving both has length sqrt(2).)

Turbo14
Turbo14

if they are both pressed divide move by 2. Probably the easiest solution.

Alberth
Alberth

In 3D, 1+1 vector doesn't necessarily make it a 2 vector. That only works correctly if both vectors are fully aligned. Ie (1, 0, 0) + (-1, 0, 0) is much shorter than length 2.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.