All Questions


yousef bohadi

getting a float value for the clamp method

hello, I keep getting the error [ Assigned type (Vector2) doesn't match the function argument's type (float).] for the code written in lines 30 and 31 in the video. Is there another way to get the x and y values as floats for the clamp function in 3.2? Thank you
  • Nathan Lovato replied

    You can only clamp one component of the vector at a time the way we did in the video. Double check you are only working with one vector component:

    velocity.x = clamp(velocity.x, ...) and NOT velocity = clamp(velocity.x, ...) or velocity.x = clamp(velocity, ...). That should clear the error.

  • b
    yousef bohadi replied

    Yeah it turns out I missed specifying the x and y values in -max_speed. Meaning they should have been -max_speed.x and -max_speed.y. Thanks for the help!

  • Nathan Lovato replied

    You're welcome, glad this helped!