How are you calculating the force vector? Are you using a radian / angle and converting it to a unit vector and then multiplying a force magnitude value?
it = it or 0
function init(self)
it = it + 1
print("I'm here", msg.url())
--local dir = math.pi / math.random(1,10)
dir = it / 10
local heading = vmath.vector3(math.cos(dir), math.sin(dir), 0)
local power = 75000
local force = heading * power
msg.post("#collisionobject", hash("apply_force"),
{force = force, position = go.get_world_position()})
timer.delay(3, false, function() go.delete() end)
end
Ok, but does it even matter? I used just vmath.vector3(0,12000,0) - why is it bad if the result of calculating angles and multiplying is also a vector3? I donât know why it would be non deterministic? Does the moment of applying forces depends on the frame or something? I have no idea
I have tried the repro and, in my opinion, there Is something strange.
The equation of motion of a free body under Gravity Is Linear. This implies that the movements along different axis are Independent.
If I apply the force (0, 12000, 0) or the force (4000, 12000, 0) I must get the same behaviour along the Y axis. And this Is not what I see in the repro.
Maybe init Is not the right Place to apply forces? And, more important, for how long the msg apply_force applies the given force? This must be guaranteed to be constant along the simulation.
Indeed, what change velocity Is the product F*DT, where F Is the force and DT Is the interval of time the force Is applied.
I apologize for the length of this post about elementary physicsâŚ
The two forces have the same Y components, so the mass should move in the same way along the Y axis (this is the superposition principle). And, if I understand, @Pawel is reporting that it is not.
The X components are different, hence the movements along X are different. So the total push is different as @Mathias_Westerdahl has said.
Is your example project really the same as the one in your gifâs?
In both cases, the particle dies after 2 seconds, since you have the timer set to 2 seconds.
When running it, it does not look like your second gif for me.
before go.delete() in ball.script in order to print the last value of Y before the deletion. This SHOULD be independent of the X component of the force applied to the body.
When the force (4000, 12000, 0) is applied I see ây = 129.16âŚâ
When the force (10000, 12000, 0) is applied I see ây = 86.15âŚâ
I hope this may help to explain the âstrange behaviorâ reported by @Pawel
Ok, so I think I get misunderstood. Itâs not about a magnitude - itâs constant in both cases (doesnât matter, that it has a different magnitude). The strange behavior is that in the vertical shot presented in the second gif in my first post, normally the ball is deleted before falling below the starting point, but sometimes, the ball is falling below it:
That sounds more like an issue related to the way you are deleting the object somehow. Could you modify your test to have a timer of dt increment inside the scriptâs update instead of using timer.delay() and see if you still see the odd behavior?
Worth noting in your uploaded example the group and mask are the same value. So since you create and destroy at the same interval, itâs possible that sometimes the creation happens before deletion where there are 2 objects in a single frame which pushes a ball downward on spawn to create an illusion? Try alternating the orb color too.
I didnât notice I wasnât changing collisionobject groups nor masks It explains the issue, ball was simply colliding with other and was bumped up, and it was noticed only in a vertical shot, because in the leaned shot there were no collisions Moreover the timing in the first gif I uploaded was so bad, that the created ball was bumped down by a ball falling just before it was deleted.
Different collision groups vs overlapped collision groups.
However it seems to me that the problem I mentioned in my last post about the Y final position that should be independent of the X component of the force is still there. And there is no collision involved.
I have to say that I do NOT use physics, so my interest in that problem is limited but if someone want to investigate furtherâŚ