Clickteam Fusion 2.5

### Clickteam Fusion 2.5

View Stats:
Rakashis Apr 27, 2014 @ 12:17pm
Collision force? - Physics Question
I will quote a question that was made in a forum outside Steam that is pretty much self explained and it's almost exactly the same question I am having right now, maybe I am not the only one. :)

quote -> "Hi. First off great job with the physics, wonderfully simple, beautifully integrated, enormous fun, and just what the series needed.

However, as a human my first instinct is to smash stuff together (i.e. if two objects of the same type hit with enough momentum, they'll take damage and eventually break) and I'm trying to figure out the best way to do this. There doesn't seem to be a built-in method for determining force of impact.

I can't use speed because two objects moving in the same direction very quickly may glance off each other but not have enough relative speed that they should do damage. Now...

If I was using two different object types I could approximate their mass by using the x and y edge coordinates to approximate area and multiplying by density. I could then calculate the x and y components of the velocity to determine the difference in speed for each component and thus the relative impact speed, which I could then, using the approximate mass, turn into a momentum or 1/2mv^2 energy transfer to each, determining how much damage should be applied to each object. My question is:

1. The engine must already do this - so is there an easier way?
2. Is there a more precise way to determine mass, other than counting pixels for each object?
3. If I do need to take this approach, how do I get it to work for two objects of the same type/group? How do I ensure I'm looking at one of their velocities/masses, then the other's, then both added together, all in the same collision statement? Can 'for each' do this, and if so how does it work? (I've had limited luck so far).

If you're taking requests a 'compare force on object to a value' statement would be INCREDIBLY useful.

Many thanks,

James" <- end of quote

as my own questions, are there any plans for this upgrade to be implemented in CF 2.5?, if not, can you point me in the right direction on how could I get this working?, I was thinking with a LUA plug in, but I don't really know.

Rakashis
victorzvyagin Apr 27, 2014 @ 2:39pm
Thats a really good question, I wondered about as well- as far as I know, there are such values as Object's mass and Velocity (at least speed, don't quote me on mass- to be confirmed )
But I agree, it would be nice to have an option like that built in to the engine.
francois Apr 28, 2014 @ 11:32am
Hello,

This is François one of the programmers of Fusion 2.5 (along with Yves Lamoureux). Actually, I am the one who did all the Box2D implementation, movements, objects and all.
I will do my best to be more present in the future on Steam for technical help.

Getting the force of the collision to make an object explode based on it. Yes, this is a very valid point. That honestly, I did not think about when programming the stuff. This is not native in Box2D.
In Box2D, an object has a density, and a shape. The mass is calculated based on this two parameters by the engine. One second... Boot Fusion, drop Engine object, check the expressions... It seems, that unfortunately, I did not implement the GetMass function of Box2D within the Physics - Engine object. Which is stupid of me really. From the real mass, based on the real shape of the object returned by the engine and the velocity, you would have all the information you need (with a little sine and cosine work) for what you want to achieve.
Appart from using pre-set values for each object of your game for the mass, that you would have to define by hand (change and try process), I see no solution today to solve that. Maybe someone else has an idea?
Implementing getmass is easy, as an expression in the Physics - Engine object (but has to be ported on all platforms too).

I'll add that to the todo list. Cannot say unfortunately when this will be released. But this is a valid, and important point necessary to make a real physics game.
A cool option would be to automatically cut the graphics of the objects in pieces, and make them go in the proper directions from the collision. Maybe when we have 100 programmers working on the product. Please each one of you, buy 10 copies of the product on Steam :)

Francois