jadvrodrigues / ProjectileShooting

Easy-to-use versatile projectile shooting solution that takes both velocity and acceleration into consideration.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Projectile Shooting

Versatile solution that takes both velocity and acceleration into consideration for accurate projectile targeting. The mathematical explanation by DMGregor can be found here.

Main Functions (from Ballistics class)

  • Vector3 CalculateShootVelocity(Vector3 targetStartPos, Vector3 targetVelocity, Vector3 targetAcceleration, Vector3 projectileStartPos, Vector3 projectileAcceleration, float projectileSpeed, out float duration)

1. Shooting at the pink target at different speeds.

  • Vector3 CalculateShootVelocity(Vector3 targetStartPos, Vector3 targetVelocity, Vector3 targetAcceleration, Vector3 projectileStartPos, Vector3 projectileAcceleration, float duration)

2. Shooting at the purple target, hitting it after different durations.

How To Get Started

Clone or download this repository and open the project in Unity. Alternatively, you can copy the contents of Assets/Ballistics to an existing project.

The scenes used for the GIFs are available in the Assets/Examples folder. Just hit the Space Bar in play mode to test it.

Note: This project is using the Unity 2022.3 LTS version.

About

Easy-to-use versatile projectile shooting solution that takes both velocity and acceleration into consideration.


Languages

Language:C# 100.0%