Posted: 17th Aug 2011 18:23
Hi,
Playing with physics example I'm trying to push a ball, I achieve it using SetSpritePhysicsVelocity, what is not recommended in the manual, but SetSpritePhysicsForce doesn't work..

I basically set the point of impact in mouse coordinates but nothing happens..

any clue?
Posted: 2nd Dec 2011 7:26
Having the same problem... or a similar one.

The force is applied only for that frame of animation, so you have to keep calling it...

do
sync()
SetSpritePhysicsForce(2,10,10,10,-100)
loop

The problem I am having is that it is not applying force to the COM (center of mass)... so it just rotates.

Is there not a function to apply a force to the COM of a sprite???
Posted: 2nd Dec 2011 10:20
Here's an example of how to add forces to sprites:
+ Code Snippet
rem Landscape App
SetDisplayAspect( 4.0/3.0 )

setPrintSize(3)

createSprite(1,0)
setSpriteSize(1,4,-1)
setSpriteOffset(1,2,getSpriteHeight(1)/2)
setSpritePosition(1,50,50)
setSpritePhysicsOn(1,2)

rem A Wizard Did It!
do
    Print("Left Click to apply a vertical force on the sprite")
    Print("Right Click to apply a pointer based force")
    if getRawMouseLeftState()=1
        setSpritePhysicsImpulse(1,getSpriteXbyOffset(1),getSpriteYbyOffset(1),0,-10)
    endif
    if getRawMouseRightState()=1
        dx# = getSpriteXbyOffset(1)-getPointerX()
        dy# = getSpriteYbyOffset(1)-getPointerY()
        fx# = 142-dx#
        fy# = 142-dy#
        setSpritePhysicsImpulse(1,getPointerX(),getPointerY(),dx#,dy#)
    endif
    
    Sync()
loop