Posted: 18th Aug 2011 13:25
Hi!
I'm just wondering if someone could help me out with this command, as I'm trying to make some kind of force (wind box) that push a ball when it goes through the wind box but my attempts has been completely unsuccessful.

reading the help docs I notice that maybe they are wrong, as they talk about an ID but any ID is passed through...

Sorry if the solution is obvious but I appreciate so much some help!
thanks!
Posted: 20th Aug 2011 1:10
Can you post some example code you are using to test and I'll do my best to fix it.
Posted: 21st Aug 2011 13:45
I agree with Paul - we need to see the code.

Anyway...

You might try SetSpritePhysicsForce instead. Here is some code I used to test the application of two dimensional forces. Gravity is currently turned off. You can turn on the y component by replacing 0 with 10/scale#.

+ Code Snippet
remstart
Set simulation run time runtime#
Set the scale scale#
Set initial x position x0#
Set initial x velocity v0x#
Set x acceleration ax#
Set initial y position y0#
Set initial y velocity v0y#
Set y acceleration ay#
When the program runs, an object will move across the screen based on the settings above.
After runtime# seconds or v is greater than vmax, the positions and velocities will be displayed.
The values are to be compared with those calculated from the basic equations of physics.
remend

runtime# = 5 ` simulation run time (in seconds)
scale# = 0.04 ` scale (in meters/pixel)

m# = 10 ` mass (in kilograms)

x0# = 0 ` initial x position (in meters)
v0x# = 15 ` initial x velocity (in meters/second)
Fx# = 10 ` x force (in Newtons)

y0# = 0 ` initial y position (in meters)
v0y# = 15 ` initial y velocity (in meters/second)
Fy# = 10 ` y force (in Newtons)

vmax# = 600*scale# ` maximum speed (in meters per second)

setvirtualresolution(480, 320)
setprintsize(12)
sync()
sync()
sync()

setphysicsscale(scale#)
setphysicsgravity(0, 0)
setphysicswallbottom(0)
setphysicswallleft(0)
setphysicswalltop(0)
setphysicswallright(0)

//loadimage(1, "body.png")
createsprite(1, 0)
setspriteposition(1, x0#/scale#, y0#/scale#)

setspritephysicson(1, 2)
setspritephysicsmass(1, m#)
setspritephysicsvelocity(1, v0x#*(0.2/scale#), v0y#*(0.2/scale#))

tstart# = timer()

do

    timeElapsed# = timer() - tstart#

    setspritephysicsforce(1, getspritex(1), getspritey(1), Fx#/scale#, Fy#/scale#)

    ax# = Fx#/m# ` x acceleration (in meters/second^2)
    x# = getspritex(1)*scale# ` x position (in meters)
    xcalc# = x0# + v0x#*timeElapsed# + 0.5*ax#*(timeElapsed# * timeElapsed#) ` calculated x position (in meters)
    vx# = getspritephysicsvelocityx(1)*scale# ` x velocity (in meters/second)
    vxcalc# = v0x# + ax#*timeElapsed# ` calculated x velocity (in meters/second)

    ay# = Fy#/m# ` y acceleration (in meters/second^2)
    y# = getspritey(1)*scale# ` y position (in meters)
    ycalc# = y0# + v0y#*timeElapsed# + 0.5*ay#*(timeElapsed# * timeElapsed#) ` calculated y position (in meters)
    vy# = getspritephysicsvelocityy(1)*scale# ` y velocity (in meters/second)
    vycalc# = v0y# + ay#*timeElapsed# ` calculated y velocity (in meters/second)

    v# = sqrt(vx#*vx# + vy#*vy#)

    if (timeElapsed#) >= runtime# or v# > 0.99*vmax#

        printc("run time:  ")
        print(runtime#)
        printc("time elapsed:  ")
        print(timeElapsed#)
        print("")

        printc("ax (m/s^2):  ")
        print(ax#)
        print("")

        printc("x (m):  ")
        print(x#)
        printc("x (m) should be ")
        print(xcalc#)
        print("")

        printc("vx (m/s):  ")
        print(vx#)
        printc("vx (m/s) should be ")
        print(vxcalc#)
        print("")

        printc("ay (m/s^2):  ")
        print(ay#)
        print("")

        printc("y (m):  ")
        print(y#)
        printc("y (m) should be ")
        print(ycalc#)
        print("")

        printc("vy (m/s):  ")
        print(vy#)
        printc("vy (m/s) should be ")
        print(vycalc#)
        print("")

        printc("v (m/s):  ")
        print(v#)
        printc("vmax (m/s):  ")
        print(vmax#)

        sync()

        repeat
        until getpointerpressed() = 1

    endif
    sync()
loop

end
Posted: 22nd Aug 2011 0:35
wow!
thanks a lot!!!