How do I do to stop dragged objects into obstacles

0 favourites
  • 12 posts
From the Asset Store
Obstacle Impacts and Cartoon voices, will makes your game more funny!
  • How to make the object with Physics behaviour, stop at obstacles while being dragged (Drag and drop).

    Thanks

  • Please check my example on this topic. https://www.scirra.com/forum/viewtopic.php?f=147&t=103985

    I believe that the same rule can apply to your needs.

  • Try Construct 3

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

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

    It's similar, but In my case the object must continue to be dragged so I can take it to another place. In my project the object returns to the original place when I drop it.

  • I am sorry, I don't understand what you mean by "the object returns to the original place when I drop it". I thought that you want upon collision for the drag&drop behavior to stop acting. The "while" events in my example ensure that there is no overlapping between the sprites, I guess that since you use the Physics Behavior that wouldn't even be necessary because the detection is very tight by it's own with physics.

    Can you share a capx file to clarify your needs?

  • Hi eli0s,

    I meant that the object needs to be dragged constantly, without crossing any obstacle, until reach the goal. For example, this simple CAPX that I shared, the goal is to bring the cup to the water without going through the bucket without being dropped before. From what I saw in your project, the object stops being dragged every time that touch the obstacle and I need to click again to drag it.

  • So, what happens when the object touches the orange frame? It resets its position at the startx, starty coordinates?

    Nevertheless, what you really need is a "Pick" action, as opposed to the "Drop" that the Drag&Drop behavior already has. That way you would drop the object every time it overlaps and pick it up again automatically if the mouse were still pressed.

    To be honest, I can't think of something useful. The closest I got is without using the Drag&Drop behavior, with a simple "set position to" mouse.X, mouse.Y action (you can lerp it for smoother movement) and a boolean that becomes false when the object overlaps with the container and stops the "set position" action. The problem is that when it stops the overlapping and we re-enable the "set position", the result is a jagged movement as the object collides and re-collides constantly with the container. Also, if you sweep the object fast enough, you can even pass thru the container, since the 60fps aren't enough to check for the collisions.

    Sorry that I couldn't be of more help.

  • Also.. check this one:

    You can save the X and Y of the object into a variable as soon as a touch event happens. When you release it you canset an action to force/impulse towards those coordinates.

  • Hi eli0s,

    So, what happens when the object touches the orange frame? It resets its position at the startx, starty coordinates?

    The object just can not cross the orange sprite and must continue to be dragged without release the mouse button.

    [quote:3vhrwoh3]Nevertheless, what you really need is a "Pick" action, as opposed to the "Drop" that the Drag&Drop behavior already has. That way you would drop the object every time it overlaps and pick it up again automatically if the mouse were still pressed.

    This solution seems to be interesting. Could you make an example using CAPX that I have shared?

    [quote:3vhrwoh3]To be honest, I can't think of something useful. The closest I got is without using the Drag&Drop behavior, with a simple "set position to" mouse.X, mouse.Y action (you can lerp it for smoother movement) and a boolean that becomes false when the object overlaps with the container and stops the "set position" action. The problem is that when it stops the overlapping and we re-enable the "set position", the result is a jagged movement as the object collides and re-collides constantly with the container. Also, if you sweep the object fast enough, you can even pass thru the container, since the 60fps aren't enough to check for the collisions.

    It's true. I tested it and didn't work.

  • Hi henriquesv

    I tested this action and didn't work for me. If you can, please, use my CAPX to show your solution. Thanks.

  • This solution seems to be interesting. Could you make an example using CAPX that I have shared?

    Unfortunately, such an action doesn't exist. I've stated the lack of it on this topic (https://www.scirra.com/forum/viewtopic.php?f=146&t=104264) which criticize the lack of controlling some behavior parameters thru actions. I don't rate this need as high enough though, I doubt that Ashley will prioritize this any time soon.

  • Unfortunately, such an action doesn't exist. I've stated the lack of it on this topic (https://www.scirra.com/forum/viewtopic.php?f=146&t=104264) which criticize the lack of controlling some behavior parameters thru actions. I don't rate this need as high enough though, I doubt that Ashley will prioritize this any time soon.

    Surely not. Thanks anyway.

  • I still need some help with this issue. Any other solution, please?

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