Breakable Objects

0 favourites
  • 8 posts
From the Asset Store
Do you need to break something? It’s okay, we’ve got you covered. No damage, danger or clean-up needed!
  • I want to have a physics object break realistically when it collides with another physics object. Very similar to Angry Birds. The problem is that I would have to add one event for each possible case which could easily get to 20 events.

    Also, how can I get it to play an animation instead of just disappearing?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yup, was about to post this question too, anyone can help here?

    Thanks in advance.

  • I'm very interested too...

    Based on the mass and the velocity of two objects, how can I determine which of them will be broken when they collide? (like in Angry Birds and other similar games)

    Thanks in advance, too! <img src="smileys/smiley30.gif" border="0" align="middle" />

    Rag

  • If you want to break object to two or three pieces you should create this pieces first. When you break this object spawn this three pieces.

  • Thx <img src="smileys/smiley16.gif" border="0" align="middle" />

    But what I don't know is : how can I know when it is consistant to break on objet or another?

    For example, in real life, if you throw a fragile object on a stone wall at high speed, this object will be broken and the wall won't be. But if you throw, on the same wall at the same speed, let's say... a canonball, the wall will be broken ! (eventually)

    And if you throw the fragile object at low speed, it won't be broken.

    Know what I mean? I'd like to understand and apply this consistency with C2.

    Thanks in advance <img src="smileys/smiley27.gif" border="0" align="middle" />

  • Well, you kinda wrote the solution yourself by explaining it <img src="smileys/smiley17.gif" border="0" align="middle" />

    I haven't much experience on C2, but I think the method to C Classic is similar.

    If:

    objects speed is over XXX

    object 1 and object 2 are colliding

    object 1's private variable(fragile) = 1

    then

    object 1 = break.

    That would be my approach.

  • This is my attempt at making it decide whether an object should break or not:

    dl.dropbox.com/u/52788071/break_events_01.png

    So it adds the speed of both of the objects together and if it is greater than the breaking speed, it gets the angles that both are moving at as well as the angle between their coordinates. If at least two of those are the same (give or take 45 degrees), the object will break.

  • If we ask mister Physic, he will talk about kinetic energy (Ek)

    Ek = 1/2 *mass*speed^2

    So what you would want to know is what is the Ek applied to an object.

    And based on it's fragility (which could be an instance variable) you could break it or not.

    Well fragility... It could really be just Hit Point. This way you can hit the same object many times until it break.

    Also, the mass would be another instance variable.

    So we just need to know the speed of the first object relatively to the other one.

    Well wait a minute

    obj1 has an Ek1 ->   Energy impact = Ek1+Ek2   <- obj2 has is own Ek2

    well it's true only for a frontal impact.

    So how to evaluate non frontal impact?

    You probably have to project the velocity vector of obj1 onto the velocity vector of obj2

    Yeah I guess it would be like that:

    Sprite1: On Collision with Sprite2
       Local Variable v1X  // Sprite1.Physics.VelocityX (for simplification)
       Local Variable v1Y  // same
       Local Variable v2X  // same
       Local Variable V2Y  // same
       Local Variable v1   // Sprite1 velocity projected to Sprite2 velocity
       Local Variable v2   // Sprite2 velocity
       Local Variable ECollision //Energy generated by the collision
       //Simplification
       -> System: Set v1X to Sprite1.Physics.VelocityX
       -> System: Set v1Y to Sprite1.Physics.VelocityY
       -> System: Set v2X to Sprite2.Physics.VelocityX
       -> System: Set v2Y to Sprite2.Physics.VelocityY
       //we get (more or less) the Magnitude of the vector (v1X,v1Y) projected on v2
       -> System: Set v1 to -cos(angle(0,0,v2X,v2Y)-angle(0,0,v1X,v1Y))*distance(0,0,v1X,v1Y)
       //Magnitude of the vector (v2X,v2Y) (actual speed)
       -> System: Set v2 to distance(0,0,v2X,v2Y)
       //Energy of the collision
       -> System: Set ECollision to 0.5*Sprite1.mass*v1^2 + 0.5*Sprite2.mass*v2^2

    Then you just have to use the value of ECollision as a Damage value. Decreasing HP of your sprites and breaking them if it's too high.

    This calculation should also work if obj2 try to move away from obj1, the damage should be less than if obj1 is immobile.

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