Drag & Drop physics question

Get help using Construct 2

Post » Sun Nov 25, 2012 12:40 pm

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 ^^ Toby122012-11-25 13:14:21
B
11
S
2
Posts: 43
Reputation: 1,411

Post » Sun Nov 25, 2012 12:44 pm

https://www.dropbox.com/s/epdgymhsbjc92w9/Drag%20and%20drop.capx

Link the the capx.
B
11
S
2
Posts: 43
Reputation: 1,411

Post » Sun Nov 25, 2012 2:01 pm

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.Kyatric2012-11-25 14:02:09
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Sun Nov 25, 2012 5:13 pm

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 -

https://www.dropbox.com/s/6gnqvoxhuouacq5/First%20version.capxToby122012-11-25 23:03:09
B
11
S
2
Posts: 43
Reputation: 1,411

Post » Wed May 07, 2014 5:35 pm

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.
B
65
S
13
G
2
Posts: 969
Reputation: 6,732


Return to How do I....?

Who is online

Users browsing this forum: flemmig, Matthew de, semaso, Skebab, Virpoja, Yahoo [Bot] and 25 guests