BAM BAM Update v337

FP Prehit work very great at 600fps.
I am very very pleased to read this. I understand the resistance and all that for lower specc'ed PCs but and might not be so noticeable on a 60Hz monitor but with the faster monitors of today? You don't want to go back to 60Hz again (at least i don't :p ).

The advantages of more resolution in a simulation is the one thing that is worth it no matter the cost. Accuracy and realism is what all this is about so why keep away from it? It's like buying something on impulse and then let it rot in a corner.
 
I am very very pleased to read this. I understand the resistance and all that for lower specc'ed PCs but and might not be so noticeable on a 60Hz monitor but with the faster monitors of today? You don't want to go back to 60Hz again (at least i don't :p ).

The advantages of more resolution in a simulation is the one thing that is worth it no matter the cost. Accuracy and realism is what all this is about so why keep away from it? It's like buying something on impulse and then let it rot in a corner.
On my laptop, i have a 120hz... it work very very very great :-D:-D
 
Hi Rav,
I am finally having a lttle look at some of the new BAM stuff

@JLou5641 asked if there was a way correct OutVelocity based on prehit contact point.

Particularly to adjust OutVelocity.x a little especially if ball is hits the tip of the flipper

It other words for example lets say Prehit contact point is > .7 , to make the OutVelocity.x = OutVelocity.x + 100 after ball is hit by the right flipper

I called the correction value "RightFlipperVelocityXCorrection"

Code:
Dim RightFlipperVelocityXCorrection

Sub RightFlipper_prehit()
   If BAM_VERSION < 233 then Exit Sub
   OnPreHitFlipperSettings(RightFlipperExt)
  If (RightFlipperExt.ContactPoint => 0.7)  then
         RightFlipperVelocityXCorrection = 100 'or whatever'
      End if
End Sub

Sub RightFlipper_hit()
ball.SetVelocity ball.OutVelocity.x + RightFlipperVelocityXCorrection,ball.OutVelocity.y, ball.OutVelocity.Z
End Sub

What would you recommend ?
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.
 
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.
I don’t think

Sub flipper_hit is a thing is it Rav ?

I mean I don’t flippers generate a hit event ?
 
Last edited:
The closest i've seen on this is FlipperExt.Hit inside Sub OnPreHitFlipperSettings(FlipperExt)... Could be a solution, passing the flipperExt from a _prehit?

But I think @ravarcade meant it generally. Usually you'd have sub flipper1Ext_hit() much like _prehit? Assuming it does work obviously.
 
This is "working" demo.
A stupid one.
Main problem is to determine if ball was hit and will fly away from flipper or it just hit is and will roll over it.
I have no idea how to do it right.

Small explanation.
Rules:
1. After ball hit flipper, wait 1 physics frame and modify ball velocity (add something to X)
2. If you add something, wait next 10 frames before ball may hit flipper again.

So, we have 3 variable for ball:
ball.ExtInt1 - counter decremented every physics frame. When flipper hit ball, it is set to 2, so we skip single frame
ball.ExtFloat1 - value to be added to ball velocity x.
ball.ExtInt2 - another counter. It counts from 10 to 0. So, we can check in "_hit()" subroutine if 10 frames passed and we can modify ball speed after hit again.
 

Attachments

  • f-demo.fpt
    223.5 KB · Views: 46
stupid one.
Main problem is to determine if ball was hit and will fly away from flipper or it just hit is and will roll over it.
I have no idea how to do it right.
Can you explain ? Why it's need to determine that in your opinion ?
 
This is "working" demo.
A stupid one.
Main problem is to determine if ball was hit and will fly away from flipper or it just hit is and will roll over it.
As this is a post hit change in velocity we can apply it only it if ball trajectory and ball speed meet our criteria
I have no idea how to do it right.

Small explanation.
Rules:
1. After ball hit flipper, wait 1 physics frame and modify ball velocity (add something to X)
2. If you add something, wait next 10 frames before ball may hit flipper again.

So, we have 3 variable for ball:
ball.ExtInt1 - counter decremented every physics frame. When flipper hit ball, it is set to 2, so we skip single frame
ball.ExtFloat1 - value to be added to ball velocity x.
ball.ExtInt2 - another counter. It counts from 10 to 0. So, we can check in "_hit()" subroutine if 10 frames passed and we can modify ball speed after hit again.
Thanks so much again Rav !
That should give Jlou and Anon a good start !
 
Last edited:
@JLou5641
@ravarcade
@AnonTet
@shiva
@GeorgeH
@Paolo
@Gin
@NitroNimbus
@TerryRed

JLou and Anon are wondering about adjusting the Velocity.x after you hit the ball with flipper.

This intial demo just shows how it might be done in principle.
If you wish to make the adjustment based on prehit contact point (For example only applied to tip shots or whatever) then that can be
added to the prehit code.

This rough demo is applying the correction to all contact points (whenever the ball hits the flipper)

Here is a tweak to rav's demo above.
It should now not apply his code when ball is rolling down the flippers.
I corrected for trajectory and the Velocity.x factor will only be applied if ball is rolling up the table towards the backbox

Code:
Sub NewtonPhysicsTick()
    BallTrajectory  = Atn2( xBAM.Ball.Velocity.X, xBAM.Ball.Velocity.y )
    'AddDebugText "BallTrajectory = " & BallTrajectory
    If BallTrajectory < 90 or BallTrajectory > 270 then AdjustBallVelocity()
End Sub

Also I added a parameter for LeftFlipper and RightFlipper called LeftFactor and RightFactor for testing purposes.

If you use "B" and "V" on keyboard it will keep adding or subtracting 100 to Right and Left Flipper velocity.x correction

If you play in debug mode by pressing F9 from table editor it will show the values.


I also recommend using the flipper testing tool under bam menu "physics tweaks"
I can show people how this works if they don't know
 

Attachments

  • OutVelocityJLou.fpt
    224 KB · Views: 59
Last edited:
It seems to work surprisingly well thanks Rav !
It will be interesting to see if this offers any benefit over or in addition to our prehit flipper Omega correction approach.

Now we have correction (flipper omega) applied DURING the hit and another correction (outvelocity.x ) applied AFTER the ball is hit

Here is a video demonstrating the flipper testing tool . I have the ball being repetitively released above the right flipper as a demo.
And I keep pressing "B" or "V" on keyboard to see the effect of the various values.

View attachment velocitry.x.mp4
 
It seems to work surprisingly well thanks Rav !
It will be interesting to see if this offers any benefit over or in addition to our prehit flipper Omega correction approach.

Now we have correction (flipper omega) applied DURING the hit and another correction (outvelocity.x ) applied AFTER the ball is hit

Here is a video demonstrating the flipper testing tool . I have the ball being repetitively released above the right flipper as a demo.
And I keep pressing "B" or "V" on keyboard to see the effect of the various values.

View attachment 21923
what a good news! I was sure that BAM FP could be not bad as lot of people think.
I can't test it seriously for now. I'll be busy for the weekend. So, if someone want, here the link on my last version of addam's family i made Yesterday with my last update with Rotation Charts and Physics. Trajectory and timing are good, but need some velocity adjustement to resolve some problem and make trajectory that not possible for now.

 
Gimli,
It was all about rav implementing outvelocity and JLou idea to use it. I can't be credited for this.
 
Thanks @Gimli for your video and help. You make me happy with this.. Can't wait to test it. I have some idea in my head. It open a great gate to make better physics.. Thanks @ravarcade for your work
@AnonTet , you can be credit for it too.. We work together since few month to make better physics, you help me a lot, explain me a lot how FP work, and make me think that FP BAM has the potential too be better realistic. When i thinking about @TerryRed pinevent table, Dynamic lightning of BAM and Extra features, i'm sure we can make it better than a simple pinball game with "shitty" physics. @AnonTet , i think we make good work in few month for better physics. So you can be Credit for this too, like Gimli, like Rav.. Me, i have just ideas, I understand, use and update things that already exist.. i'm not a "advanced script creator"
 
@Gimli @ravarcade , I make a fast test... an whoaaaah! It's working crazy! :clap::clap: @GeorgeH, @shiva and other.. Try it!
How we can change value for velocity correction ( ex: add or reduce 10 instead of 100 ), and how to show contact point in debug mod in same time of velocity correction?

I'm pretty sure that with velocity correction we couldn't need Omega Correction any more in DF script, and so, it will be easier to find good value for Omega cause we could test in live with different Omega by BAM menu, instead of changing OMEGA in DF script, Launch it, test, exit, update, launch, retest, re-exit etc etc..
 
@Gimli , I update the code. Velocity correction need to be disable when flipper are "standby" at 0° when you want to let the ball roll, or at full ramp up ( 48° by default for me ) when you want to control the ball... Otherwise, ball accelerate or have retro effect, or "autobouncing"

Code:
Sub LeftFlipper_preHit()
    If LeftFlipperExt.angleDiff > 0 and LeftFlipperExt.angleDiff < 48 then
        If LeftFlipperExt.Hit And xBAM.Ball.ExtInt2 = 0 Then
            xBAM.Ball.ExtInt1 = 2
            xBAM.Ball.ExtFloat1 = LeftFactor
            AddDebugText "L"
        End If
    End If
End Sub

Sub RightFlipper_preHit()
If  RightFlipperExt.angleDiff > 0 and  RightFlipperExt.angleDiff < 48 then
    If RightFlipperExt.Hit And xBAM.Ball.ExtInt2 = 0  Then
        xBAM.Ball.ExtInt1 = 2
        xBAM.Ball.ExtFloat1 = RightFactor
        AddDebugText "R"
    End If
End Sub
 
I tried Gimli demo and then mod by JLou posted above (right flipper needs a second "End If").

I don't understand what you are trying to accomplish.
 
I tried Gimli demo and then mod by JLou posted above (right flipper needs a second "End If").

I don't understand what you are trying to accomplish.
First, to resolve trajectory issue for the tips and base that we talk with @ravarcade in this Topic:

Second, make adjustement for angle of shoot.. Exemple, on Real Adam's Family, you can shoot the lockball door with the near base of right flipper... Today, in FP, you can't.. Shooting near the base is too wide, and too make it close, you need to add more Omega, but then, Omega is too strong... With Velocity Corrector, you can correct this without "cheating" with OMEGA.
 
That's a generic problem (the tip of the flipper sending the ball too wide) so this is not simply a solution to that table. I have to find the time to update a table with this code now. if it works as is, probably this can be yet another c&p solution to update other tables.
 
Well, to be honest it was always a problem (the wide shots). If memory serves me well was also the cause for high flipper angles along with strong omega... blah blah. old history. we're moving forward now :D
 
Well, to be honest it was always a problem (the wide shots). If memory serves me well was also the cause for high flipper angles along with strong omega... blah blah. old history. we're moving forward now :D
I can’t see it replacing Omega correction but we’ll see.

The other bug that needs fixing currently is that the correction currently wrongly activates if the ball comes down inlane when you hold the flioper.

I think this can be corrected by adding a prehit restriction based on flipper angle .
 
think this can be corrected by adding a prehit restriction based on flipper angle
See above @Gimli , I add this 😉.
Also, how I can change velocity step in debug mode ( 10 instead 100 for exemple ), and watch contact point at the same time?
 
Oops
See above @Gimli , I add this 😉.
Also, how I can change velocity step in debug mode ( 10 instead 100 for exemple ), and watch contact point at the same time?
opps sorry just saw that…
 
Forum activity
Help Users
You can interact with the ChatGPT Bot in any Chat Room and there is a dedicated room. The command is /ai followed by a space and then your ? or inquiry.
ie: /ai What is a EM Pinball Machine?
  • No one is chatting at the moment.
      Mibs Mibs: StevOz has posted a new reply in the thread "Post interesting videos you found on YouTube".
      Back
      Top