New answers tagged aiming
Try fixing parenthesis: var pitch = Math.atan((v*v+Math.sqrt(v*v*v*v - g*(g*x*x+2*y*v*v)))/(g*x)); var pitch2 = Math.atan((v*v-Math.sqrt(v*v*v*v - g*(g*x*x+2*y*v*v)))/(g*x)); Consider also using atan2 function. Maybe in your case it won't fix anything but it's always good to know about it. https://en.wikipedia.org/wiki/Atan2
This can be achieved using trigonometry and vector mathematics. First, calculate the direction (or normalized vector) that the turret should face: Where a is the target vector subtracted by the turret position: direction = Vector2.Direction(targetPos - turretPos); Assign this value to a Vector2 direction inside your bullet class. You should to ...
Luckily it's pretty simple! To have a turret shoot a bullet at a target point, you need to figure out the normalized vector from the turret to the target. To get this, first subtract the target point from the turret point. This gives you a vector but the length is not normalized. To normalize this vector, you just divide x and y by the length of the ...
Top 50 recent answers are included