• Detecting Circular Movement
    7 replies, posted
How would you detect if something, say your mouse, is moving in a circle within a particular region? How could you make it to varying degrees of accuracy?
I'd say this wasn't really a Newbie question ... :O Firstly you can use [url]http://wiki.garrysmod.com/?title=Gui.ScreenToVector[/url] to get the position that the mouse is. You'd could probably figure it out by storing the most recent points within perhaps 1/4 of a second intervals and then calculate their positions relative to each other to see if it had made a circle. Though maths was never my strong point so I can't help you much there. Just really hate maths. / Fist shake. I'm sure someone else who is more awake will post with better advice soon though.
You could store the position of the entity/mouse over a time and then compare the angles between the positions. If all of the angles fall within a certain margin from their preceding ones, they are advancing in a circular path.
My question is, why do you need this 0_0
Volume control for his music player. To style like an iPod. That's my guess ;)
[QUOTE=Nevec;17675434]You could store the position of the entity/mouse over a time and then compare the angles between the positions. If all of the angles fall within a certain margin from their preceding ones, they are advancing in a circular path.[/QUOTE] Yeah, that would work. Just gotta do the math now. Thanks Nev. [QUOTE=Skapocalypse;17678182]Volume control for his music player. To style like an iPod. That's my guess ;)[/QUOTE] QUIET YOU!!
Volume control doesn't work too well in Gmod, I've played with it and the sound difference is minimal.
[QUOTE=Nevec;17675434]You could store the position of the entity/mouse over a time and then compare the angles between the positions. If all of the angles fall within a certain margin from their preceding ones, they are advancing in a circular path.[/QUOTE] Uh, I said that before lol. Guess I just worded it wrong. Had been awake over a day at the time. x3
Sorry, you need to Log In to post a reply to this thread.