How do I Drag-and-Drop Wall Block

0 favourites
  • 13 posts
From the Asset Store
Now you can drop everything in your game with sound :)
  • Hi,

    I am attaching a Drag-and-drop project where I try to block the object to pass through immovable object.

    The walls have physics behavior and are immovable. The dragged object has the behaviors drag-and-drop and physics.

    I also tried to use the Solid behavior for the walls, but saw no effect.

    Any ideas?

    Someody suggested to use "drop" action when collision happens... but the game playability wouldn't be nice.

    Thank you!

  • Use physics forces! When you use the drag'n'drop behavior you move the object direct to the x and y position to the touch position. So the physic collision is can't work correctly. Because it instantly move to this position every tick.

    Drag'n'drop is a really primitive feature. Its better you create your own movement with events.


    1. Add a Variable to you player object named "move = 0".

    2. Go to the Event Sheet 1 and Create a Event "On Touched object" Sprite2 (Player).

    On this Event: Set the variable "move" from player object to "1".

    3. Create a "On any touch end" and reset the variable to "0".

    4. Create a Event "Compare instance variable" of player object if "1".

    5. Now you can add a physical force. For example:

    "Apply force towards position"

  • You can fake a mouse joint, create an invisible sprite that follows your mouse position on everytick, when you click on a block create a joint between the block and the invisible sprite, on click up, destroy that joint. I haven't tested it, just a thought.

  • You can also move the object directly over Set_velocity(x,y). Just set the distance beween self.x/y and touch.x/y multiply with force

  • Nice Dag! It is working!

    I have attached the example if anybody needs it in the future!

    caiorosisca, could you please give me an example of mouse joint? I didn't get the picutre...


  • Try Construct 3

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

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

    I need to solve this same issue, but I would like to use force toward position to get more realistic effect.

    Do you have any example of how to apply it? Or even an example about your suggestion in the first reply? Thanks anyway.

  • RenatoB, I have improved it a little bit (to my needs). I will post it here ASAP.

  • Thanks, henriquesv

  • You're welcome! Please wait until the end of the day... =)

    Too much work around here.

  • Try this instead: Set Physics velocity to ((Touch.X - Object.X) * 10, (Touch.Y - Object.Y) * 10)

    Before, I've tried "Force" and "Impulse".

  • Did this "Set Physics velocity to ((Touch.X - Object.X) * 10, (Touch.Y - Object.Y) * 10)" work?

  • Did you happen to finish that example? I'm curious how you got it to work.

  • Hi! I didn't have time to finish it.... can you believe it? I will let you know!

    Still the objects are in a sling-shot behavior =)

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