All Questions

Community

z
Zoidberg zoidbergforpresident

Clamping a vector x and y is not the same as clamping the vector, right?

That way you'll clamp the movement on the x and y axis independently and not clamp the whole movement, right?
  • Nathan Lovato replied
    Vector2.clamped(length) is going to limit the length of the vector, preserving its direction (or "angle"). When you clamp the X and Y components separately, on the other hand, you may change the direction of the vector. So they're not the same thing, you're correct. Now, the reason we're doing that is just because it's easier for us to control the horizontal and vertical movement separately in a platformer. For different kinds of movements, like a car in a top-down game, you may need to always work with vectors and use something like Vector2.clamped instead.
  • z
    Zoidberg zoidbergforpresident replied

    Cool info, thanks!