Vector woes

Hi guys

Just started working on a kind of variation on an angry birds type game, although the projectile has a fixed velocity rather than the ability to adjust power. I have set the control mechanism up with an aiming cursor which can be dragged, with its position constraining to x and y attributes. When you press fire a projectile is spawned travelling along a vector angle (using the x and y positions of the player who is static and the x and y attributes created above). I have assigned an acceleration attribute which acts as gravity on the projectile, making it move in a parabolic fashion like a bullet.

I have tried to implement a distance attribute which can be adjusted by the player, ie. if the target is far away, increase this number to add to the vector angle, which makes the projectile travel at a steeper angle than the initial vector set by the aiming cursor, with the idea being similar to adjusting a scope on a rifle.

The issue I have is that this works fine until the aiming cursor's x position changes. Even if the distance attribute value stays the same, the closer the cursor is to the player on the x axis, the steeper it fires. The farther away, the shallower it fires. I need the angle to stay the same regardless to the cursors x position, otherwise the system wont work!

The distance attribute is set as an integer which adds to the vector angle created - is this the wrong way to go about it?

Hope this makes sense!!!!

Comments

  • doodleswagdoodleswag Member Posts: 9
    I'm thinking I have waffled on too much or not explained myself properly haha
  • doodleswagdoodleswag Member Posts: 9
    Was hoping for help on this one, but I figured it out last night! The wind and distance attributes needed to be added to the vector itself, not within the brackets of the vectortoangle behaviour, I now appear to have fully working 2D ballistics with the ability to zero weapons B-)
Sign In or Register to comment.