Trick Shot
Last updated
Last updated
Support us as a GitHub Sponsor and get instant access to all our assets, exclusive tools and assets, escalated support and issue tracking and our gratitude. These articles are made possible by our GitHub Sponsors ... become a sponsor today!
This tool's primary purpose is to plan the flight of a projectile including bounces given the settings you define on it and ensure the projectile follows that path in a physically accurate way.
The tool is most useful when you need to ensure that the projectile will hit and bounce in a particular way such as in puzzle games or similar.
This tool DOES NOT handle the aiming of the projectile, it simply calculates the path that will be followed given the projectile settings and manages the projectile along that path. Aiming can be done through the Ballistics API or the BallsiticsAim tool.
Available for 3D Physics
And for 2D Physics
The speed of the projectile to be used
this is the global constant acceleration applied to the projectile over the life of its flight. At minimal this would be at least gravity (0, -9.81, 0) by default.
You can use the Constant Acceleration component to calculate a dynamic constant force at run time. This is useful if you want to use local effects such as the Magnus effect which is the effect produced by the local spin of the projectile in flight and is generally calculated as local to the emitter.
Global effects can be applied directly to the field on TrickShot by summing up the values.
The radius of the projectile body to be used
For 3D
For 2D
The projectile template is to be spawned when the Shot method is called.
The distance between each step to be calculated there is no reason for this to be any smaller than speed multiplied by the average frame time and is generally best served as speed * fixed delta
The max distance the trajectory will be calculated for. This is arc distance, not linear distance.
What layers should be tested for collisions
How many times should the projectile be permitted to bounce before the calculation is ended?
This is how much energy will be lost for each bounce and is similar to Unity's "bounciness" values in the Physical Material and Physical Material 2D. For example, if you set a "bounciness" of .8 then you would use a "bounceDamping" of .2 meaning 20% of the energy is lost on each impact.
Should the distance be measured as arc length from the start or should it be considered for each bounce independently?
For 3D
For 2D
This is the resulting path predicted by the tool. each entry in the list represents 1 "segment" aka "path" where a segment is "bounce to bounce" Thus if you have 2 entries then there was at least 1 bounce.
Updates the prediction based on the current settings.
Instantiates the template and sets it on the current predicted path.