How do I Drag-and-Drop Wall Block

Get help using Construct 2

Post » Fri Apr 11, 2014 3:33 pm

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!
You do not have the required permissions to view the files attached to this post.
B
24
S
4
G
1
Posts: 177
Reputation: 1,827

Post » Fri Apr 11, 2014 5:00 pm

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.

Example:
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"
B
13
S
4
G
1
Posts: 107
Reputation: 1,337

Post » Fri Apr 11, 2014 6:01 pm

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.
Please tag me with @caiorosisca if your post is refering to me :). I don't always follow the topics I answer.
B
11
S
4
G
1
Posts: 272
Reputation: 1,643

Post » Fri Apr 11, 2014 8:47 pm

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
B
13
S
4
G
1
Posts: 107
Reputation: 1,337

Post » Sat Apr 12, 2014 12:08 am

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...

THANKS!!

:mrgreen:
You do not have the required permissions to view the files attached to this post.
B
24
S
4
G
1
Posts: 177
Reputation: 1,827

Post » Wed May 07, 2014 5:30 pm

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.
B
74
S
13
G
4
Posts: 1,006
Reputation: 8,060

Post » Wed May 07, 2014 8:50 pm

@RenatoB, I have improved it a little bit (to my needs). I will post it here ASAP.
B
24
S
4
G
1
Posts: 177
Reputation: 1,827

Post » Thu May 08, 2014 10:29 am

Thanks, @henriquesv
B
74
S
13
G
4
Posts: 1,006
Reputation: 8,060

Post » Thu May 08, 2014 11:29 am

You're welcome! Please wait until the end of the day... =)
Too much work around here.
B
24
S
4
G
1
Posts: 177
Reputation: 1,827

Post » Fri May 09, 2014 1:19 am

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

Before, I've tried "Force" and "Impulse".
B
24
S
4
G
1
Posts: 177
Reputation: 1,827

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 13 guests