How do I (Stuck draggable object?)

Get help using Construct 2

Post » Sat Jun 28, 2014 2:44 am

Hello everybody!
Inform anyone know how I could make a draggable object by mouse standing in a kind of box, and this object can not exceed the walls of this box?

Can anyone help?
B
11
S
3
G
1
Posts: 105
Reputation: 1,135

Post » Sat Jun 28, 2014 4:54 am

I'm not 100% sure I know what you want, but I think I get it..

in the case of the game i'm working on, I had a problem with the physics because I could drag a box through the walls of the truck.. to get around this, I added a local variable to my box objects, and when the box collides with any of the walls this variable "hittruck" goes from 0 to 1.

then i have a rule for the dragging that this variable must be 0 to drag..

http://part12studios.com/temp/FredexTest2/

here is how the logic is setup.. and if i follow you correctly, this should help you with your problem:

Image
B
59
S
9
G
1
Posts: 939
Reputation: 6,545

Post » Sat Jun 28, 2014 5:12 pm

https://www.dropbox.com/s/sdsysnf558a1d ... ocked.capx

What I'm trying to make is that the green ball, can not exceed the blue walls.

Can anyone help?
B
11
S
3
G
1
Posts: 105
Reputation: 1,135

Post » Sun Jun 29, 2014 2:31 am

i tried to make your drag drop thing work, but i think that's the problem. i believe you should roll your own drag/drop function.. making something that doesn't have this need to declare the function on/off could be hanging up the result you want.

box behavior
Image

box properties
Image

this is pretty much exactly what you need.. at the very bottom.. see where it says BoxA on collision with truck walls set hittruck to 1. this "Breaks" the grip and the box remains inside the container.. and you can still grab the box again..

on any touch end you see at group 5, you have any touch end reset the hittruck value.
B
59
S
9
G
1
Posts: 939
Reputation: 6,545

Post » Sun Jun 29, 2014 3:15 am

I've made an example for somebody before.
Take a look at this screenshot and see if that helps your issue:
Image
For your case you will do this 4 times for each side of the box.
While you're dragging the ball outside the box, the ball will stay at a certain y or x depending on what side you are dragging your mouse
B
6
S
1
Posts: 73
Reputation: 571

Post » Sun Jun 29, 2014 7:22 am

B
33
S
5
G
1
Posts: 163
Reputation: 2,693

Post » Sun Jun 29, 2014 8:22 am


when you touch the blue wall, it sticks to the wall and the drag & drop is removed. Is there any way when you touch the blue wall and continue having the drag drop without stops?

Thx :D
B
13
S
2
Posts: 297
Reputation: 1,717

Post » Sun Jun 29, 2014 2:34 pm

@Scofano, there is an error in this example, because if you hold the ball and throw it against the wall, it will exceed, and in my case this could not happen.
B
11
S
3
G
1
Posts: 105
Reputation: 1,135

Post » Sun Jun 29, 2014 2:59 pm

If you release the button make it stop = no throw
B
33
S
5
G
1
Posts: 163
Reputation: 2,693

Post » Sun Jun 29, 2014 3:06 pm

@Scofano, I can not use his example and do use, I've tried many different ways. But when the ball crosses the walls.
B
11
S
3
G
1
Posts: 105
Reputation: 1,135

Next

Return to How do I....?

Who is online

Users browsing this forum: Fenix18, tarek2 and 54 guests