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. Implementing this code is very similar to the rubber dampeners covered in a previous post and requires an update to some of the existing code.
Start by creating your drop target. This method requires a second drop target created in the same location as the first, but 1 vp unit wider and 5 vp units thinner. This second drop target is used to prevent ‘side’ hits from dropping the target. Only hits to the face of the target should cause a drop. You will need to make sure you drop and raise this second target along with the original in your script.
Next we’ll add all the targets with the same orientation to a collection. For the purposes of this tutorial, we’ll call the collection dDropTargetsR. Next we’ll add the following code to our script (make sure the collection is set to fire for hit events).
A couple of notes.
The following line is used to grab the orientation of the drop targets from one of the targets in the target bank.
DropsR.angle = DropBall15.Orientation
Setting the mass determines how much resistance the drop target will provide on the ball. It should usually be a value less than the mass of the ball if you want the ball to pass through the target. However, you may set it higher than the mass of the ball to kick the ball back without passing through the target. I recommend a low value like 0.5, but there are some instances where you may want to increase this to slow the ball down.
DropsR.mass = 0.5
These functions contain and update corTracker function. This updated code is backward compatible with the rubber dampening functions, so it’s safe to replace the old function in your existing tables. You will also need to add a new timer in the editor called “RDampen”. Enable it with an interval of 1. Add the following to your script if you’ve not already add cor.update for rubber dampeners:
I’ve included Big Shot here with this code implemented.