Collisions and solids

For questions about using Classic.

Post » Wed Jun 20, 2012 8:20 pm

I'm trying to make a room with boxes you push and pull around.

It's a top down game and I'm a bit lost as to why the boxes don't collide correctly with each other. Been using CC for about a week so I'm not very well versed in this.

The boxes are marked as solid but they go through each other when pushed, if I activate physics they both move when they collide, which I guess makes sense since they're all the same mass.

What I want is the box I'm pushing to halt completely upon touching another box, like in Zelda games. I've tried speeding up the boxes and it achieves the same result as moving the box pixel by pixel.

What can I do to achieve this effect?

EDIT: Oh, the boxes have a CustomMovement behavior.ninefingers2012-06-20 20:31:29
B
3
Posts: 7
Reputation: 289

Post » Wed Jun 20, 2012 8:50 pm

Assuming this happens even when trying to move the boxes using actions from the CustomMovement behavior...You will need to have a variable to stop pushing I think and set it to 1 when the boxes overlap.

Also use the "Push out of object at angle" action for CustomMovement to push the box out of the one it collided with towards the player (away from the box the way it was pushed in).
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Wed Jun 20, 2012 10:09 pm

Thanks! the variable worked.

This now may sound really stupid, I don't know, but I haven't figured out how to make it so I can move the box in directions other than the direction the boxes are touching in.

Thing is, I'm making a variable for each direction the boxes might touch at, but they all activate at the same time because the condition they have to make the boxes stop pushing is the same in all of them. Is there a way to make the variables change only when one box touches a specific angle of another box?
B
3
Posts: 7
Reputation: 289

Post » Wed Jun 20, 2012 10:20 pm

Should be able to say "Push out at opposite angle" I think =S
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Wed Jun 20, 2012 10:52 pm

Doing that just seems to teleport the boxes to different coordinates.
B
3
Posts: 7
Reputation: 289

Post » Wed Jun 20, 2012 11:02 pm

Ah, then if you can do "Move at angle" for the box being pushed try this angle:

"angle(Player.X, Player.Y, Box.X, Box.Y) * -1)"

and move at this speed:

"<whatever player speed is> + 1"

Might need to remove the * -1 bit above to get the right angle value, but I think what I put is correct.Jayjay2012-06-20 23:02:39
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Thu Jun 21, 2012 1:40 am

The behavior of that was really buggy, so I started from scratch using 8-direction behavior (with the available directions reduced to 4) and using Set Position to move the boxes. It worked without variables or anything.

I'm basically just saying this so if another person has the same issue they might find a solution online.

Thanks,Jayjay, you were really helpful though!
B
3
Posts: 7
Reputation: 289

Post » Thu Jun 21, 2012 3:52 am

Ah glad to hear it worked out in the end ninefingers, I was wondering if my method would look alright.
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Thu Jun 21, 2012 6:31 am

Well, it mostly kept changing the order of the boxes and pushing them out away from where they were, but if I kept moving them around, eventually they started working properly.

I don't know if I did something wrong though, being a newb and all.
B
3
Posts: 7
Reputation: 289

Post » Thu Jun 21, 2012 6:17 pm

Hmmmm, I have another problem. Now I'm allowing the boxes to be pulled, but the player character warps to a different location when I approach another box from behind while pulling.

I have variables that tell the box I'm pulling to stop moving if the player overlaps another box at an offset of (15,0)(-15,0)(0,-15) and (0,15) in either direction but they don't stop the box from moving.

Any idea what is wrong?
B
3
Posts: 7
Reputation: 289

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest