Drag & Drop physics question

0 favourites
  • 5 posts
From the Asset Store
Now you can drop everything in your game with sound :)
  • I have two collision objects; one immovable (the floor as it were) and one movable (the ball).

    I've added a sort of drag and drop behavior to the ball using physics, the problem is that the ball will pass through the floor object. I was wondering if there was a way to stop this? I think it's something to do with the ball being set to the position of the lmb is down, but I'm not quite sure how to go about cancelling this when it hits the collision point of the floor.

    I've searched the forums for a solution, but have had no luck so far and tried various methods, i.e. destroying the ball on contact but it's not quite the result I'm after. Will continue to read the manual and try different things in the mean time :).

    Link below.

    Thanks for reading :)

    EDIT: Just as a little side note, I added the link in the reply not to bump my post but I couldn't see the edit button initially ^^

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • According to the tutorials about physic (basics; advanced), it is bad practice to, as you did, set an instance (with physic behavior) to another position in the screen. It "teleports" the instance instead of applying forces to it resulting in non expected behavior and bug in the physic world.

    I think you should take it back from the start, define/explain exactly what you want to do (an object, that has such interactions with another one, what are those interactions, what are the interactions you don't want to see), and then we can propose you some implementations.

  • Hi,

    Firstly I'd just like to say thanks for your reply :). I want to be able to interact with the "ball" in a way which allows me to drag it around the screen (whilst clicking and holding on it with the lmb) and then once released will fall and stop on the immovable object (the floor).

    The problem I have is, during the process of dragging, positioning the ball you can drag it through the immovable object. This is the interaction that I want remove.The result i'm looking for is that when dragging, when the "ball" hits the floor, it will only roll a long it etc (move left to right visa versa) but not below the floor.

    It's basically the achieve the placement of physical objects :).

    Is this of any more help?

    EDIT 1: One partial solution seems to apply physics force to the mouse x and y position. It means you can drag the object through the immovable one. However, it's not exactly smooth and the object rotates circularly around the pointer on the screen.

    EDIT 2: Did some more searching on the forum, found your thread on mechanics and such. Have a partial solution (from a capx your linked + I added in few physics events). Only issue is, I can't seem to get more than one object working at the same time without it going crazy. Here's a link -

    dropbox.com/s/6gnqvoxhuouacq5/First%20version.capx

  • Hi Toby12

    I've the same issue. Could you publish the CAPX again for I check if it has the solution that I need, please? Thanks anyway.

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