I'm making an Angry Birds like game and I need to limit the distance that the user can pull back the slingshot, how do I do this?
Tell me more
×
Game Development Stack Exchange is a question and answer site for
professional and independent game developers. It's 100% free, no registration required.
|
Get the length of the vector from the slingshot to the mouse/finger/whatever. If it's more than your allowed length then normalise the vector (to make its length 1) then multiply it by the maximum length. Note, to avoid a square-root (costly operation) in the first bit compare the length squared with the max length squared.
|
|||||||||
|