Figuring out Bullet Patterns
|
During the past week I was assigned with making a couple of “bullet patterns”. By bullet pattern I mean the way the bullet acts when fired by an entity within the game world. So Essentially it is the act of how the entity shoots and how the bullet moves when shot. The purpose for this was to have as little code as possible, and making it easy for our designer to give each enemy a unique shooting pattern. I quickly came up with the idea of having different shooting scripts for the different patterns that we might want to implement. Among these bullet patterns we wanted one that could shoot in a straight line in any direction specified, one that could shoot projectiles in a circle, and one that could shoot a bullet that followed a sine curve within any direction. Figuring out how to shoot in a straight line seemed easy enough and it was. And the circular pattern was removed as it essentially turned out to just be repeatedly using the straight pattern with different directions. The sine pattern however proved to be a little bit tricky, a sine curve looks like this: Shooting directly to the left or to the right worked flawlessy, but I realised that it would not work if I wanted to shoot in any other direction. So I asked a relative about how he would go about solving this problem and he told me that I would need to move the y and x axis based on the character’s rotation like in these pictures: Overall I would say I am pretty happy with how it turned out, even if it might not be the best code performance wise, it gets the job done. |


