Code/Example BAM Expanding Spinning Disks with BAM

Coding and examples for future Pinball and BAM

Wecoc

Pinball Wizard
Joined
Dec 7, 2021
Messages
66
Reaction score
105
Points
40
Favorite Pinball Machine
Cirqus Voltaire
Even though default Spinning Disks work pretty well (and the XML allows customization), with BAM we can also recreate them using a Trigger and two Timers instead, which allows some extra features.

- You can read exactly when the ball enters or exits the spin disk

- You can do something exactly when the spin disk stops rotating completely
By default, you can only read that "motor-wise" instead of "rotation-wise"; with a Trigger you have more control.

- You can get the current angle by script
Some pinballs use the Spinning Disk as a roulette, but you can't do that with a default Spinning Disk.
Instead, using a Trigger, you can simply get the current angle with SpinDisk.Rotation
You can even rotate it manually to a certain angle or do a defined number of spins.

image-29.jpg

Spinning disk roulette in No Good Golfers. Image from IPDB.

I believe the road "pointer" in the pinball Formula 1 works similarly.

- The spin disk affects the ball, but the ball doesn't affect the spin disk
The ball can cause the default FP spin disk to rotate a little when disabled and when passing over it slowly. That's not very realistic for normal spin disks, and also would cause problems on the roulette case already mentioned, so this doesn't happen anymore. It could of course be implemented back as well, by expanding the code.

- You can control via script the damping and motor power of the spin disk
You can now create custom values for those parameters. The damping was tweaked because the default one was way too loose.
There are also new parameters like the "Resistance" (speed reduction of the ball when it passes through the disk), and also "Spin Effect" (how much of the disk rotation affects the ball's trajectory)

The concept of Resistance is very similar to speed-modifier magnets, which can also be made using a Trigger. When hit, the velocity of the ball is simply multiplied by a factor.

Code:
xBAM.Ball.SetVelocity xBAM.Ball.Velocity.X * 0.85, xBAM.Ball.Velocity.Y * 0.85

This is useful because some classic spinning disks had a certain "roughness" texture to slow the ball. An example would be the two disks in Casino.

You could make more advanced effects based on the current angle of the spin disk. Some classic pinballs use that, for example Twin Win or Fireball.

- You can use sphere mapping to create spinning metal plates
Some classic pinballs use metal spinning disks, and using a Trigger allows that very easily.
You can also disable "Render model" and use an extra Toy, matching its rotation with the trigger's rotation. By doing that, you can make translucent spinning disks and place a bulb below, which also appeared on some classic pinballs.

For some examples of translucent spinning disks, see Star Action and Planets.

The Demo includes a default spinning disk (right) and the new one using the code (left) for comparison. It also includes the three models (large, medium, and small).
 

Attachments

  • SpinDiskDemo.fpt
    298.5 KB · Views: 12
Last edited:
Good idea, but i think it not usefull.
Simply because a "trigger-spindisk" don't have material.. You can't set his friciton for exemple. On your spindisk, ball just sliding and stop spinning..... But it should, because this is very important for ball behaviour when she leave Spindisk

- The spin disk affects the ball, but the ball doesn't affect the spin disk
The ball can cause the default FP spin disk to rotate a little when disabled and when passing over it slowly. That's not very realistic for normal spin disks, and also would cause problems on the roulette case already mentioned, so this doesn't happen anymore. It could of course be implemented back as well, by expanding the code.
To make the ball not affect the spindisk, it's just a XML setup.
- You can use sphere mapping to create spinning metal plates
You can put a sphere mapping on FP spinning disk. Just put a non-collidable surface at 0.1 height


The only benefit I see from you Spindisk, is that you can count the number of rotation, mean you have more control. Is it really usefull?

In conclusion, your idea is good, but you need to make same thing, as diverter model, not trigger model.
Diverter model have SetMaterial possiblities, custom name, sphere mapping. And to active it convert your ornement hole as a trigger.
Then it will be perfect.
 
You can control the ball's friction both when it enters the trigger and leaves it with Hit and UnHit; in that sense, the parameter "Resistance" acts pretty much like a material behaviour. Even though the diverter has those parameters in the XML and this trigger requires setting them via script more blindly, the trigger is still required because of those two functions. Furthermore, your solution of using a trigger as the hole is not much different than my example of using a trigger without the "Render" option and a toy, and indeed in that case you could use a diverter instead, but for most cases it's just overcomplicated.

As you will see in the demo, the ball acts very similarly in both the default Spinning disk and the trigger one ;) While making it, I even tried putting a semicircle wire to "trap the ball" and rescue it using the disk's rotation, and it still works as expected.

You can put a sphere mapping on FP spinning disk. Just put a non-collidable surface at 0.1 height
A surface doesn't rotate. With my method, you have both sphere mapping and rotation on the same object! :-)
 
You can control the ball's friction both when it enters the trigger and leaves it with Hit and UnHit
Nope, i assure you, you can't. Trigger have no any physic material parameter.. No bounce, no friction. What you do can't be called Friction.
Take the manual ball roller, ball will "slide"/move like your parameter tell... But it not make the ball spinning... So if you will use real friction value like we use for FizX on XML, you will have weird behaviour and bad trajectory transition between spinner and playfield.... because the lack of friction on a trigger model... And i don't see any code of ball.omega wich "emulate" ball spinning depend the spining of your Spinner... Even if you use it, because we can't read the ball Omega, you will "break" the good spinning of the ball. Omega is also a parameter that need to be taking account like you made for velocity.


As you will see in the demo, the ball acts very similarly in both the default Spinning disk and the trigger one ;) While making it, I even tried putting a semicircle wire to "trap the ball" and rescue it using the disk's rotation, and it still works as expected.
Because there is no great physics parameter. ( "no" ball mass, "no" gravity, "no" friction... by default, all of this are like hellium balloon )

A surface doesn't rotate. With my method, you have both sphere mapping and rotation on the same object! :-)
but no spinning and rolling friction.. Which is the most important things

Good XML make spinner working great.
 
Fogort to mention that using ball.setvelocity work great with one ball... but in mulitball it more complex than that... Otherwise, all ball will be affected if i remember right
 
Maybe Rav can add BAM feature for spindisk... Like custom omega, mass and other like he made for flipper and ball
 
You're right there's no omega because I didn't go that far, and I don't think there's any need (normal Spinning disks don't have any of that). The interaction with the playfield when the ball exits the disk doesn't seem to be a problem, though. You can change the SpinDiskResistance to a very low number in the demo to see how the material property changes; with 0.25 the ball reduces a lot of its speed when passing through the spinner, but also accelerates when it gets back to the playfield.

As I said, I made some tests to make sure it works very close to the real spinning disk, and it's not completely identical but it seems to do the trick.

It's hard to show this on video without trying to spin the disk yourself, but here are some of my tests.

spindisk.gif

This test was made on an early stage, the flippers control the speed and direction of the disk.
The rotation of the disk affects the ball very similarly to the real one.

If you increase SpinDiskEffect, the ball will spin a lot more (or in other words, the disk won't need that much force to spin the ball).
If you decrease SpinDiskResistance, the difference on the ball speed when entering/leaving the disk is way more noticeable.

spindisk-B.gif

The diverter would help to set the physics, but I'm not sure how would that really work with manual rotation, and probably at that point there's no advantage from using a normal spinning disk instead. I also don't like the idea of tweaking the diverter's physics for the spinning disk if the playfield uses normal diverters as well, it doesn't seem compatible at all.

Fogort to mention that using ball.setvelocity work great with one ball... but in mulitball it more complex than that... Otherwise, all ball will be affected if i remember right

I didn't implement multiball, but using the BallID that should be doable. You can also use "BallCloseTo", and the balls can be tracked as well. It makes the code more messy, but the functions and the math are basically the same.
 
Last edited:
use this XML:

Code:
'=============================== PHYSICS XML ===========================
'<?xml version="1.0" encoding="utf-8"?>
'<document>
'  <physics slope="7" fps="592" threaded="1"></physics>
'  <ball newtonDamping="0" mass="8000" gravity="9810" damping="0.250"></ball>
'  <flipper rotationSpeedChart="{0.0,100.0}[0.0,0.0],[160.0,100.0]"
'        newtonDamping="1" releaseOmega="18" mass="500000" omega="45" moeMethod="0" leftXoff="0" leftYoff="0" leftZoff="0" rightXoff="0" rightYoff="0" rightZoff="0"></flipper>
'  <bumper impulse="60.0" impulseRandomness="0" vectorRandomness="2"></bumper>
'  <autoplunger mass="1000000.0" force="30000.0"></autoplunger>
'  <diverter mass="1000000.0" omega="30.0"></diverter>
'  <gate mass="0.5" gravity="3000.0" damping="1.0"></gate>
'  <kicker impulse="1000.0" vukImpulse="1400.0" impulseRandomness="0" vectorRandomness="0"></kicker>
'  <plunger mass="1000000.0" force="30000.0"></plunger>
'  <slingshot impulse="0" impulseRandomness="0" vectorRandomness="0"></slingshot>
'  <spindisk mass="100000.0" angularDamp="0.1" linearDamp="0"></spindisk>
'  <spinner mass="99999.0" gravity="9810.0" angularDamp="0.5" angularAccel="5.25"
'           spinDampLoose="0.30" spinBackLoose="0.65"
'           spinDampNorm="0.40" spinBackNorm="0.65"
'           spinDampTight="0.70" spinBackTight="0.65"></spinner>
'  <emkicker mass="1000000.0" omega="80.0"></emkicker>
'  <varitarget mass="500.0" damping="0.9" tension="3.0" return="15.0"></varitarget>
'  <magnet impulse="10.0" impulseRandomness="2"></magnet>
'  <nudge impulse="120.0" impulseRandomness="25.0" warningLevel="250" leftAngle="60" upAngle="0" rightAngle="320" vectorRandomness="5" visualDistance="1" waitPeriod="300" maxBallVelocity="500.0"></nudge>
'  <defaultMat softnessCoef="1" elasticCoef="0.1" staticFriction="0.2" kineticFriction="0.2"></defaultMat>
'  <playfieldMat softnessCoef="1" elasticCoef="0.1" staticFriction="0.03" kineticFriction="0.03"></playfieldMat>
'  <metalMat softnessCoef="1" elasticCoef="0.4" staticFriction="0.3" kineticFriction="0.1"></metalMat>
'  <woodMat softnessCoef="1" elasticCoef="0.3" staticFriction="0.2" kineticFriction="0.02"></woodMat>
'  <plasticMat softnessCoef="1" elasticCoef="0.2" staticFriction="0.2" kineticFriction="0.02"></plasticMat>
'  <rubberHardMat softnessCoef="1" elasticCoef="0" staticFriction="1" kineticFriction="1"></rubberHardMat>
'  <rubberIntMat softnessCoef="1" elasticCoef="0.65" staticFriction="0.75" kineticFriction="0.6"></rubberIntMat>
'  <rubberSoftMat softnessCoef="1" elasticCoef="0.85" staticFriction="0.75" kineticFriction="0.6"></rubberSoftMat>
'  <gateMat softnessCoef="1" elasticCoef="0.65" staticFriction="0.02" kineticFriction="0.02"></gateMat>
'  <kickerMat softnessCoef="1" elasticCoef="0" staticFriction="1" kineticFriction="1"></kickerMat>
'  <rampMat softnessCoef="1" elasticCoef="0.1" staticFriction="0.2" kineticFriction="0.02"></rampMat>
'  <plungerMat softnessCoef="1" elasticCoef="0.4" staticFriction="1" kineticFriction="1"></plungerMat>
'  <spindiskMat softnessCoef="1" elasticCoef="0.01" staticFriction="0.3" kineticFriction="0.3"></spindiskMat>
'</document>
'=============================== PHYSICS XML ===========================

Then, just play with angularDamp="xx" that affect motor power, and staticFriction="0.3" kineticFriction="0.3" from spindisk.

to play easier with friction, just set both as same. Not set them more than 0.3, and less than 0.02.
I assure you it work well depend you need. We work hard with @AnonTet on how using good XML
 
About sphere map, on a pinball, spindisk are rarely "shiny"... They are often more dirty than shiny ^^
 
Maybe Rav can add BAM feature for spindisk... Like custom omega, mass and other like he made for flipper and ball
In fact, there's where I get a bit lost about your method. Wouldn't a flipper work better than a diverter?

In any case, I could try to convert the current parameters (Resistance, SpinEffect, MotorPower, Damping) to others more close to the XML (mass, angularDamp, linearDamp, softnessCoef, elasticCoef, staticFriction, kineticFriction), they could all be implemented but the final effect wouldn't look that different and it seems pretty tedious and less intuitive for the user, so I prefer to leave it as is.

My recommendation would be simply doing this:
For normal Spin disks, use the default values (0.75, 0.75, 3, 1)
For metal Spin disks, the ball speed doesn't decrease and the friction would be lower (1.0, 0.35, 3, 1)
For rubber and very "rough" Spin disks, exactly the other way around (0.35, 1.0, 1, 0)

Anyone can expand on my code if you want more options, it can be used as a base.

Also, I didn't mention this before, but using the trigger trick you can also implement aerial spinning disks, which can't be done by normal means.
By disabling the trigger's render and including a non-collidable toy that rotates the same way above the ball (this can be easily done matching their rotation values), it will look like the toy is making the ball spin from above. These kinds of disks often include transparency, so even if the normal spinning disk works from above (which I don't think it does), it still wouldn't be a valid approach :shrug_no:

Aerial spinning disks can be found in Big Together and Southpaw.
 
Bear in mind, as I said at the very start, normal spinning disks are perfectly valid and in many cases you won't need tricks like these. The one presented here is for an out-of-the-box kind of situation.

The "trigger method" is meant for:
- Roulette-like spin disks
- "Shiny" metal spin disks
- Translucent spin disks with a bulb below
- Trigger-based spin disks ("turn on" lights specifically when the ball is over them)
- Aerial spin disks
- Even more advanced special cases (see below)

The trigger spin disk could also be used for those cases where there are other things over the disk, for example posts or targets, since for that you could use a rotating mini-playfield with collision and match its rotation to the trigger's rotation.

The combination of Spinning Disk and Mini-playfield can be useful for inclined disks or for "popup" disks like in Avengers.

"Per polygon collision" doesn't work with the default Spinning disk, so if you want to make a custom Spinning disk shape, the trigger method is also better. An example of that would be Stern's version of the Spinning disk, that often includes a magnet in the middle. See X-Men or The Beatles. This also allows multiple concentric disks like in Pirates of the Caribbean.

For normal cases, use normal spinning disks with custom XML physics as the one presented by @JLou5641 :-)
 
Last edited:
You might find the spin disc on "Tales of the Arabian Nights" interesting. It only spins when the ball hits it. The mass for the spindisk is set really low in the XML and the motor power is set to minimum to make it work.
 
Thanks, @Wecoc.

The FP demos & tutorials section certainly wouldn't mind if you uploaded the demo there:

Now that the PSDB is done, I'm not sure where the best repository of FP demos might be.
Perhaps at Archive.Org or the torrents?
 
Bear in mind, as I said at the very start, normal spinning disks are perfectly valid and in many cases you won't need tricks like these. The one presented here is for an out-of-the-box kind of situation.

The "trigger method" is meant for:
- Roulette-like spin disks
- "Shiny" metal spin disks
- Translucent spin disks with a bulb below
- Trigger-based spin disks ("turn on" lights specifically when the ball is over them)
- Aerial spin disks
- Even more advanced special cases (see below)

The trigger spin disk could also be used for those cases where there are other things over the disk, for example posts or targets, since for that you could use a rotating mini-playfield with collision and match its rotation to the trigger's rotation.

The combination of Spinning Disk and Mini-playfield can be useful for inclined disks or for "popup" disks like in Avengers.

"Per polygon collision" doesn't work with the default Spinning disk, so if you want to make a custom Spinning disk shape, the trigger method is also better. An example of that would be Stern's version of the Spinning disk, that often includes a magnet in the middle. See X-Men or The Beatles. This also allows multiple concentric disks like in Pirates of the Caribbean.

For normal cases, use normal spinning disks with custom XML physics as the one presented by @JLou5641 :-)
Some of them are possible with FP spinner ;) : "Shiny", Trigger-based, Aerial spin disks, magnet, multiple concentric disks and propably Translucent spin disks with a bulb below ( but haven't in my mind if a already see a pinball with that in real on in virtual.. Could be fun ! )

But question, how do you make your trigger disk to spin ? is it this ?
Code:
If (SpinDiskCurrentSpeed <> 0) Then
        SpinTrigger.Rotation = SpinTrigger.Rotation + (SpinDiskCurrentSpeed * 2)
    End If
I didn't know that spinner object have .rotation possiblity 👍
 
.rotation work with pop too.. But pop, if i'm right, have material, and sphere map, crystal transparent, and could be popped lol.. so you can make a Pop spindisk with it "natively" ;)
 
Last edited:
you give me some idea ^^
 
@Wecoc , is there other command than .rotation that exist which could be interesting?
 
I wonder if every thing in RAVs Extention maps .txt regarding objects apply:

ObjectInfo (from xBAM.FindObject) (everything read only)
.Position
.x
.y
.z
.Rotation
.x
.y
.z
.Velocity
.x
.y
.z
.RotationSpeed
.x
.y
.z
.Exist
.Material
.lineardamping
.angulardamping
.Center
.x
.y
.z
 
those are only for reading... i doubt there is the same for writing
 
I know. But if you can read you might get an idea to do something with it even if by other creative means.
Wecoc mentioned .rotation in a read context only as well.
 
You might find the spin disc on "Tales of the Arabian Nights" interesting. It only spins when the ball hits it. The mass for the spindisk is set really low in the XML and the motor power is set to minimum to make it work.
I've played that pinball before, it's great. I don't see that lamp much like a spinning disk, though, it's more of a "spinning post", since you hit the two pegs that hold the lamp to make it rotate. There are other examples that would work fine with the same trick (normal spinning disk with altered physics to reduce its mass), for example the aerial spinning posts in Joker or even the racing cars in Mario Andretti. ;)

Now that the PSDB is done, I'm not sure where the best repository of FP demos might be.
This forum by itself serves that purpose well enough. PSBD had some resources I would like to retrieve, though.

@JLou5641
I didn't use a popup because it doesn't have the Hit and UnHit functions. I believe the trigger is the best option possible in most cases.

Rotation is not Read-only, it's what I use to spin the trigger. Editor properties are writable, although most don't update at all, so I still consider them Read-only. Rotation works well, and it's one of the "basic" ones you can play with. The collision box doesn't rotate, though, be aware of that. I talked a bit about that here.

In this case, I used it only to rotate the disk's graphic, and the physics are all via script based on the current speed of that rotation.
 
Thanks for your explanation 👍👍
 
General chit-chat
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.
      Chat Bot Mibs Chat Bot Mibs: hellrzr2k1 has left the room.
      Back
      Top