[WTA] Simulating physic using trigonometry.

Hello everyone!

I’m trying to script a game mechanic where a tank will shoot a cannon ball, there are two variables which is the shooting angle and shooting power. I want to make the cannon ball curve like an arc with regards to the shooting angle and shooting power.

Now, it is quite easy to do this using Unity built in phsyx engine. But the problem is, having the game style is cartoony one, I want to use a vector approach. I was thinking that the angle will determine how much is the elevation while the power will gives the distance. So it is just a simple arc that I wanted the cannon ball movement to be. I’m really not used to coding using trigonometry. Anyone has any hints about this?

I just can figure out the gravity part at the moment which is something like this, transform.position.y -= gravity.

Cheers.

p/s: I’m using C# to code.

Looks like I’ve figured something out.

By using trigonometry I can use sin (shooting angle) = position.y / hypotenuse (power) and cos (shooting angle) = position.x / hypotenuse (power). Then I can translate the cannon ball from its spawn position to the calculated projectile, plus the gravity it’ll give a clean arc, it would right?

But still I don’t have much experience with unity trigonometry API, any help will be highly appreciated!