Smooth mouse movement

For questions about using Classic.

Post » Mon May 17, 2010 11:31 pm

Hi guys,

Got a challenge for y'all. I've been searching the forums but haven't been able to find what I'm looking for. I want an object to move left and right on a one-dimensional plane, controlled by the left and right movement of the mouse. I want the movement itself to be smoothed, with nice acceleration and deceleration, similar to platformer movement. The up and down movement of the mouse would be ignored, since the object can only move left and right.

None of the default movement behaviors cover this. I'm sure it's something dead-simple, but I'm having a hard time wrapping my head around any kind of logic that would be used to implement it.

Can anyone point me in the right direction? I would be very appreciative, and I sincerely apologize if this has been covered already and I just missed it. Thanks!

-Ben
B
1
G
2
Posts: 2
Reputation: 629

Post » Mon May 17, 2010 11:45 pm

Try this

always> set OBJECT.x to CLAMP(object.x+((mousex-object.x)/SPEED COEFFICIENT GREATER THAN 1),(left x boundary), (right x boundary))
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Post » Tue May 18, 2010 12:00 am

Not exactly what you are looking for, but the technique is similar:

The thread: viewtopic.php?f=3&t=4728&start=11
The file: http://www.mediafire.com/file/ojmtyiiwg ... tantly.cap

Also, there is the custom movement behavior. Should work fine too.
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Tue May 18, 2010 2:08 am

Thanks guys, those both helped tremendously. Thanks for being a great community. :)
B
1
G
2
Posts: 2
Reputation: 629

Post » Tue May 18, 2010 12:31 pm

This is a bit offtopic but what is going of with this clamp thingy? It seems that all this stuff is like new fashion over here... At one moment I've never heard about it and next everyone talks about it and im still w00t? So could someone clarify it a bit for me?

Oh and the Seagull comes and collects the thanks :P (im evil)
B
11
S
3
G
4
Posts: 622
Reputation: 3,186

Post » Tue May 18, 2010 7:41 pm

[quote="Sagal":1xcekaw6]This is a bit offtopic but what is going of with this clamp thingy? It seems that all this stuff is like new fashion over here... At one moment I've never heard about it and next everyone talks about it and im still w00t? So could someone clarify it a bit for me?

Oh and the Seagull comes and collects the thanks :P (im evil)[/quote:1xcekaw6]
"clamp" is a system expression. Here is where you can learn about clamp specifically. :)
B
14
S
2
G
5
Posts: 37
Reputation: 2,777

Post » Tue May 18, 2010 8:21 pm

Ah yes thanks! Zotged kinda like explained it to me but anyways thanks ^^
B
11
S
3
G
4
Posts: 622
Reputation: 3,186


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests