Tag Info

Hot answers tagged

3

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 ...


2

Two very general suggestions -- Often in board games a good human player runs through a list of rules or if-this-then-that mentally. If you can understand what a good human player in your game would do, then it's just a matter of translating that into code. This is generally referred to as "rules-based AI". If the game is strategically simple, then ...


1

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 ...



Only top voted, non community-wiki answers of a minimum length are eligible