You will need a little different solution. It may look more complicated, but it is not.
First small simplification where to store params.
Sometime ago i have to store some extra data for every ball. So, i added few extra properties accessible from IBall.. interface.
If you ask BAM for any ball on table with
xBAM.BallCloseTo you will get that object with extra properties.
Also when any _hit() or _preHit() procedure is executed, in
xBAM.Ball you have that aditional properties of ball.
That properties are 3 integer (32bit) fields and 3 float fields.
So, when ball hit flipper (or any other object with _hit sub) you can do something like this:
Code:
Sub flipper_hit()
xBAM.Ball.ExtInt1 = xBAM.NewtonCounter ' <- store in ExtInt1 id of freame, where hit occurs
xBAM.Ball.ExtFloat1 = 10 0 ' <- store something else, like: "we want to add 100 to X velocity sometime later
End Sub
This is right way to store "something" for later use with ball.
Now, OutVelocity.
I say some time ago, that you can with it change ball velocitiy in "_hit()" subroutine.
This is not true. It not work, because when "_hit()" is called, ball velocity is not set yet. Sorry.
... But you can do it in next physics frame :) and it is little tricky.
You will need to use NewtonPhysicsTick sub. (it is called every physics step). When check every ball on table if you should adjust ball move... and do it.
Step by step.
1. You need to "AdjustBallVelocity' every physics step, so call it from NewtonPhysicsTick:
Code:
Sub NewtonPhysicsTick()
AdjustBallVelocity()
End Sub
2. Now AdjustBallVelocity needs to find all balls on table, like this:
Code:
Sub AdjustBallVelocity()
xBAM.EnumBalls 100,0,"AdjustSingleBallVelocity"
End Sub
Code above will order BAM to call
AdjustSingleBallVelocity onec for every ball for every physics frame.
3. So, we need
AdjustSingleBallVelocity subroutine as tool to adjust params, this sub have one param... ball.
Code:
Sub AdjustSingleBallVelocity(ball)
If ball.ExtInt1 <> 0 and ball.ExtInt1 = xBAM.NewtonCounter + 1 Then
ball.ExtInt1 = 0
' now is something to do for every ball once in every newton physics engine frame ... in next frame after hit
ball.SetVelocity ball.OutVelocity.X + ball.ExtFloat1, ball.OutVelocity.Y, ball.OutVelocity.Z
End If
End Sub
So, this is what should work.