Vector woes
doodleswag
Member Posts: 9
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!!!!
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