How do I use friction to attach objects with physics

0 favourites
  • 15 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hi,

    I want to use physics to have an object falling into another one and when I move the one at the bottom (receiver), then it will move the ones on top. I try playing with the friction, assuming that if the friction at the bottom object is higher, the objects on top would stick to it (unless I move it very fast), but it didn't work.

    Can anyone point me in the right direction? Is not physics what I need? (I was thinking about PIN behavior, but I do want the object to fall if you move too fast).

    Here's the capx: https://dl.dropboxusercontent.com/u/19421237/TestFriction.capx

    Thanks!!!!!

  • Creating joints in physics behaviour is about the same as the pin behaviour..

    Using compare velocity, you could break the joint if the velocity is too high.

  • LittleStain thank you!!!! Will look into it!!

  • LittleStain I tried using the limited joint, but there is a weird behavior happening. After a little bit, the shape gets stuck in the air. Besides, I have not been able to figure out the speed enough to break the joint (I thought that limited by the angle should allow me to break it without having to code the speed). Any suggestion or tutorial that you would recommend? I read all the documentation from Ashley in regards to physics, torque and everything else.

    Thanks

    New capx https://dl.dropboxusercontent.com/u/19421237/TestFriction2.capx

  • I can not open your second capx (using a plugin I don't use/have) but I had a quick look at your first one and noticed that you are using other behaviours (8direction) with physics (probably not a good idea as it can (will ?) cause problems - try to only control physics sprites with physics (eg impulse/force) )

    Here is a quick edit of your first capx - although I do think that using a a joint will give you more control id does show that the basic idea of friction will work

  • I can not open your second capx (using a plugin I don't use/have) but I had a quick look at your first one and noticed that you are using other behaviours (8direction) with physics (probably not a good idea as it can (will ?) cause problems - try to only control physics sprites with physics (eg impulse/force) )

    Here is a quick edit of your first capx - although I do think that using a a joint will give you more control id does show that the basic idea of friction will work

    Hey Rampack!

    Still making great examples I see..

    I agree that the joint will give more control and probably make gameplay a bit more predictable for the player, but tyour example is pretty nice!

  • Hey Rampack!

    Still making great examples I see..

    I agree that the joint will give more control and probably make gameplay a bit more predictable for the player, but tyour example is pretty nice!

    Hi LS - nice to have you back. I am still getting distracted with these but I am still learning / reinforcing ideas by making them.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • RamPackWobble that is amazing! only 2 lines of events???? Wow! Amazing!!! Thanks so much!!!! I will keep looking into it...

    LittleStain thanks so much also for all the support!!! and tips...

  • Hi RamPackWobble , LittleStain sorry to bother again!!!!!

    I thought it was going to be relatively easy, but I think I'm missing something.

    I'm trying to figure out the amount of boxes on top of the red one at any given moment. For this I tried to consider that Physics Velocity on Y should be 0 and it should be located at an Y <= 362 (red box estimated height). To avoid counting the boxes that are not on top of the red, I destroy them when they touch the immovable object.

    The count display is 1 at all times, I would expect to get a 2 and 3 and so on if I get more boxes on top. I would expect to get a 2 if I had 3 and lost one. etc...

    • Should I use UID per each Sprite?
    • Any idea of how can I determine that they are all above the red one?

    I kept reading the manual and looking into this the whole day, so after trying multiples approaches (none successfully), I decided to ask again

    Thanks again for any idea/suggestion or help.

  • Anyone has an idea on how to make this happen? At least a suggestion so I can look into that?

    Thanks

  • One {untested} idea.

    Place an invisible box pinned to the player but covering the area the other boxes can stack up. Then every x seconds just count the boxes in this area.

    And as I was typing another (untested) idea fizzeled across my brain cells

    How about giving each dropped box an instance variable (ivStacked ?) And then every now and again you could step through each box an set this ivStacked if it is "overlapping at offset" (positive y) and then count up these ? In fact you could probably do this offset method without the need for the ivStacked....

    Bit busy today but I will try to test this out later and post the capx.

  • While waiting for "She who must be Obeyed " to get ready...

    Using idea 1 I get ...

  • and a very quick edit later I get.

    (note this uses "families" which is only available in the non-free versions of C2)

    This is probably a better method - and just taking this a few steps further it would be a good way to add joints....)

  • RamPackWobble Wow, you blew my mind, it is really amazing. I do have access to family, which I love (it saves so much time).

    You mean joints in order to keep them on top? I'm still trying to learn how to use physics, but I will give it a try.

    Thanks so much for all the help!!!

  • You mean joints in order to keep them on top?

    Yes - as LittleStain said , it would give you much more control over the stacked boxes.

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