0 Favourites

Collisions and solids

This forum is currently in read-only mode.
  • 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.

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

  • 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?

  • Should be able to say "Push out at opposite angle" I think =S

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Doing that just seems to teleport the boxes to different coordinates.

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

  • 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!

  • Ah glad to hear it worked out in the end ninefingers, I was wondering if my method would look alright.

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

  • 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?

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