Trick Shot
Like what your seeing?
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!
Introduction
A simple tool able to predict the flight of a projectile including bounces and to "fire" that projectile for you. Simply attach this to your "emitter" e.g. the point of origin for your projectile and this tool does the rest.
Namespace
Definition
Available for 3D Physics
And for 2D Physics
Fields and Attributes
speed
The speed of the projectile to be used
radius
The radius of the projectiles body to be used
template
For 3D
For 2D
The projectile template to be spawned when the Shot method is called.
resolution
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
distance
The max distance the trajectory will be calculated for. This is arc distance not linear distance.
collisionLayers
What layers should be tested for collisions
bounce
How many times should the projectile be permitted to bounce before the calculation is ended.
bounceDamping
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.
distanceIsTotalLength
Should the distance be measured as arc length from the start or should it be considered for each bounce independently.
perdiction
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.
Methods
Aim
Aims the transform at the target using the low angle considering the gravity defined for the Physics system, the speed of the projectile and desired input target. This does not assure the target will be hit in that the target may be out of range or some object in the path.
AimHigh
Aims the transform at the target using the high angle considering the gravity defined for the Physics system, the speed of the projectile and desired input target. This does not assure the target will be hit in that the target may be out of range or some object in the path.
Predict
Updates the prediction based on the current settings.
Shoot
Instantiates the template and sets it on the current predicted path.
Last updated