Smooth mouse movement

This forum is currently in read-only mode.
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • 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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Try this

    always> set OBJECT.x to CLAMP(object.x+((mousex-object.x)/SPEED COEFFICIENT GREATER THAN 1),(left x boundary), (right x boundary))

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

    The thread:

    The file: http://www.mediafire.com/file/ojmtyiiwg ... tantly.cap

    Also, there is the custom movement behavior. Should work fine too.

  • Thanks guys, those both helped tremendously. Thanks for being a great community.

  • 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 (im evil)

  • 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 (im evil)

    "clamp" is a system expression. Here is where you can learn about clamp specifically.

  • Ah yes thanks! Zotged kinda like explained it to me but anyways thanks ^^

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)