*** UPDATED 11/1/2020***
In this tutorial, I’ll cover adding physics for drop targets that creates more realistic behavior. It allows the ball to ‘move’ through the target enabling the ability to score more than one target with a well placed shot. I’ve made some significant changes since I first posted this tutorial that hopefully will make implementing a little easier. It also handles full drop target animation, including deflection on hit and a slight lift when the drop targets raise, switch handling, bricking, and popping the ball up if it’s over the drop target when it raises.
For each drop target, we’ll use two wall objects for physics calculations and one primitive for visuals and animation. We will not use target objects. Place your drop target primitive the same as you would a VP drop target. The primitive should have it’s pivot point centered on the x and y axis and at or just below the playfield level on the z axis. Orientation needs to be set using Rotz and bending deflection using Rotx. You’ll find a hooded target mesh in the sample table below. It uses the same texture map as the VP drop targets (thanks to @bord).
Next we’ll add two wall objects. The first will be placed in the same location as the drop target. The second will be offset behind the first (as though the target is deflected).
Next we’ll start configuring the script.
First will add the CorTracker. This code tracks the velocities of all the balls on the table. It is also used by the rubber dampeners. It has been updated and you’ll need to use the attached code for the drop targets to work properly and it is backwards compatible with the rubber dampener code. Note: you will also need to add a timer named RDampen, enabled, with an interval of 1.
Then we’ll initialize all of our drop targets and set constants that control the behavior of the drop targets.
For each drop target, we’ll create a variable and set an array of values containing the following:
- Name of the primary wall
- Name of the secondary wall (offset wall)
- Name of the drop target primitive
- The switch number
- The animation state (always initialized to zero)
DT25 = Array(sw25, sw25offset, primsw25, 25, 0)
Once we’ve declared all of our drop targets, we’ll add their variables to an array named DTArray
DTArray = Array(DT25, DT26, DT27 ….)
We’ll also need to set behavioral and sound constants including the following. These should mostly work without modification if using the sample drop target mesh, but you can tweak to your own taste.
‘Configure the behavior of Drop Targets.
Const DTDropSpeed = 110 ‘in milliseconds
Const DTDropUpSpeed = 40 ‘in milliseconds
Const DTDropUnits = 44 ‘VP units primitive drops so top of at or below the playfield
Const DTDropUpUnits = 10 ‘VP units primitive raises above the up position on drops up
Const DTMaxBend = 8 ‘max degrees primitive rotates when hit
Const DTDropDelay = 20 ‘time in milliseconds before target drops (due to friction/impact of the ball)
Const DTRaiseDelay = 40 ‘time in milliseconds before target drops back to normal up position after the solenoid fires to raise the target
Const DTBrickVel = 30 ‘velocity at which the target will brick, set to ‘0’ to disable brick
Const DTEnableBrick = 1 ‘Set to 0 to disable bricking, 1 to enable bricking
Const DTHitSound = “targethit” ‘Drop Target Hit sound
Const DTDropSound = “DTDrop” ‘Drop Target Drop sound
Const DTResetSound = “DTReset” ‘Drop Target reset sound
Const DTMass = 0.2 ‘Mass of the Drop Target (between 0 and 1), higher values provide more resistance
Next we’ll add in the Drop Target Functions, which will also require a timer be added in the editor named DTAnim. The script will enable it and set the interval. This code should not need to be modified unless you are implementing on an EM or original table.
With this code, there’s no need to use the VP initialization for the drop targets. Instead, you’ll just add hit subs for each drop target like so (notice how the targets are referred to using only the switch number):
Sub Sw25_Hit : DTHit 25 : End Sub
For the drop bank reset tied to the solenoid you’ll add something like this:
if enabled then
PlaySoundAt SoundFX(DTResetSound,DOFContactors), cutout_prim1
Or a solenoid driven drop can be performed like so:
If enabled Then
I’ve included Centaur here as a sample table with this code implemented.