Hi,
I shoot bullets to the position of my mouse click and when the bullet arrives at this position it disappears.
I tried two solutions:
-
Creating a point at the mouse position with which the bullet collides and disappears - this works well most of the time, but if I click, for instance, two times and the second click position is in the same angle just below the position of the first click, the first bullet will travel to the position of the second click instead of the first one.
-
Storing the x and y position of the mouse as a variable - this seems to be the more elegant solution but here I am facing the problem that as soon as the clicks are in the same angle, all bullets will disappear at the last click-position before arriving at their actual target-position.
I guess the problem I am facing is the same for both solutions: the initial value of the variable is overwritten by the next value. So how can I make sure that the position is stored as long as the bullet is travelling and other click positions for the following bullets are also stored?
The basic structure of my events for storing the mouse x and Y position is here (the target_position object is just created for me to have a visual reference to the position):
The scene itself consists of nothing else than the turret at the bottom:
Any suggestion how I can solve this problem is highly appreciated.