How can I move physics objects?

0 favourites
  • 7 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hello!

    I am trying to make a drag&drop physics objects system using mouse or touch controls.

    How can I do that to look more realistic like in this video example?

    As you can see in the video, the object can be moved from the point that it was touched and it rotates from that point, too.

    streamable.com/8b1jh7

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Create a small physics object at the point where the mouse is clicked and attach it as rotate joint to the object you want to drag. Every tick create an impulse from this created object toward the mouse if the distance is greater than 2 pixels. Have the impulse increase linearly with the distance beyond 2 pixels with a great deal of damping. Be sure to scale the impulse with dt so it works at any tic rate.

    yours

    winkr7

  • winkr7

    Hey!

    Thanks for your response. I am really bad at physic, this is what I've manage to achieve.

    dropbox.com/scl/fi/dksjskdwlibn1pr20l7oh/DragAndDropExample_01.c3p

    Can you make the moving of blocks smoother? Also the blocks do not slide easily into the pits, why is that?

  • Perhaps someone else can look at your code. I just post suggestions.

    yours

    winkr7

  • winkr7

    Hey!

    Thanks for your response. I am really bad at physic, this is what I've manage to achieve.

    https://www.dropbox.com/scl/fi/dksjskdwlibn1pr20l7oh/DragAndDropExample_01.c3p?rlkey=w1zl85gzyjivdmqpug9dx7ok0&dl=0

    Can you make the moving of blocks smoother? Also the blocks do not slide easily into the pits, why is that?

    I had to find and install a plugin for that damn Poki to open your example.

    I reworked your example a little bit.

    dropmefiles.com/cCLY0

    Updated.

    To make it easier to insert parts, you can reduce the collision a bit, developers often give the player invisible simplifications.

  • igortyhon Hey, sorry for that plugin, I forgot to delete it :)

    I've already reduced the collision of the blocks by 2 pixels for each side.

    Is there a way to move the block smoother and not that instant that it is right now?

    More like in my example..

    Update: I set the Density of the Blocks from 1 to 5 and it works better.

  • Is there a way to move the block smoother and not that instant that it is right now?

    You can set the coordinates of the touch point like this.

    lerp(Self.X,Touch.X,0.1)

    lerp(Self.Y,Touch.Y,0.1)

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