Hey guys, I been having this issue for few days and could not really solve it, appreciated if anyone is able to help with this
The Rock will be created and throw to the location of player each time f is pressed, the mechanism works fine for 1 rock, if multiple f button is pressed, the last rock will always aim and hit the player but the previous generated rocks will be pushed higher and higher like a parabolic shape graph. is anyone able to separate the command so that each rock generated will always hit player and would not caused other rock to move up and form parabolic shape?
The velocities should be independents for each rock (a rock moving up will have negative voy and one moving down will have a positive voy), so you’ll have to convert your variable actions and conditions into object variables, and move the rocks in a for-each loop:
[code]F key pressed >> Create rock, Do = 100 to the variable vx of Rock, Do = -50 to the variable vx of Rock
For each Rock:
Do += TimeDelta() * 98 to the variable vy of Rock
Do += Rock.Variable(vx) to the X position of Rock
Do += Rock.Variable(vy) to the Y position of Rock[/code]
The code is not the same than yours but you get the idea
Lizard-13, first of all, thanks a lot for your help i tried to change the codes and it looks like this now.
Except now another problem exist that is, my angle now is at 45 degree, if my player is too far from the source that throw rocks, it is unable to reach the player, it only able to reach the target nearby to the source, further than that are not able to reach. If i change the angle to 0 degree, it is able to reach my player even if i am far from the source but the throwing speed increase really fast, but when i go near the source, the speed of the throwing rocks slow down a lot.
Well, that has to do with the physics, if you throw an object at 45 degrees and the gravity is negative, there’s no chance to reach the target:
Now, if 45 degrees means shooting upward… then no idea why it wouldn’t be able to reach the target
(btw in the first event you’ve forgotten to change a “Variable(vox)” to “Rock.Variable(vox)”)
Also, you’ve set the vox and voy in function of the distance/position (as it should be), but it seems there is no limit for them, so it’s possible that increasing the distance the velocity gets increased too.
Check the GD examples, there’s one about parabole shooting, with variable target position, and I think the initial velocity is constant, but not sure
Well still, thanks alot and i will check on those example and see appreciated for your help Lizard-13
Update: Just by changing the one variable i left of fixed the problem all velocity is constant and problem solved!
Your help means so much to me