applyImpulse(point, impulse)

Hey guys,

Anybody know what applyImpulse really DOES? I was trying to use it today (from my understanding, impulse is the integral of Force in respect to time, or the change in momentum). Seems a bit weird to use, but I was trying to use it with the following script:

gl = GameLogic
cont = gl.getCurrentController()
own = cont.getOwner()

own.applyImpulse(own.getPosition(), 10.0)

But I get an error that reads:

Traceback <most recent call last>:
    File "impulse", line 6, in <module>
SystemError: error return without exception set

Annnd a sidenote… why does Blender’s console start lines at 2? If line 1 (or line 0 in more coding environments) has an issue, the line “error” always says “line 2.” Just curious.


applyImpulse just applies a certain force at a certain location for one frame. The problem with your usage is that the force needs to be a vector, rather than one number (a scalar, right? I don’t remember my math words DX)
…also, as a side note, I think the position has its zero at the object’s center, so generally I just use [0,0,0]. it only matters if the object is a rigid body though.

also, for some reason, the error returns are always on the line before the one it says it is. not sure why, but that’s the way it is… (you can see the actual line numbers in the text editor by toggling the appropriate button in that window)

Aha, you’re right. I should have known… it just wasn’t in the gameLogic API I was using. Speaking of which, is there a newer version than the one that I’ve been looking at? It says it’s for 2.34 up on top…

Also, Impulse is DEFINITELY not force… I remember that much from my Physics class last semester. I don’t remember how to calculate its effects, but as far as I can tell, applyImpulse(point, I) sets the object’s velocity to 2 * I / M. So if you apply an impulse of 5 in the X direction to an object with a mass of 2, the object’s velocity will jump to 5 in the X direction.

Seems useful, no?


impulse is force/time, if I remember correctly, but applyImpulse is just force (according to all my experiments, at least). you can take that up with the programmers if you like…

[edit] oh yeah, and I prefer this list of functions more, tho it’s only up to 2.45 (marginally better, at least)

A vector, by definition, is a speed in a direction. So using your example, 5 is the speed, and the positive X axis is the direction. That would be a vector of [5,0,0]. What applyImpulse() does is take that force and, instead of applying it to the center of the object, as a force actuator would, it applies it to a point in relative space to the object. It would be like taking your finger a applying a force to the top of a ball, or the side of a ball.