Draw a moving line

taking a cue from the example “Zombie laser” I’m trying to simulate the same in my video game.
this is my code now

the problem arises when the player is on the move and the laser can’t keep up with him
I attach gif to understand

this thing doesn’t happen if I add the top down behavior to the player in the laser zombie example and start walking. please help me

It’s hard to figure out from the .gif what’s going on. However, I suggest you work out the contact points first, then draw, rather than draw and then work out the points.

And you can get rid of the contact flag. It’s not needed if you change the events like this :

Yeah as MrMen said you just need to let starting point of laser follow player point all the time:
For example:
No condition: Action: Laser starting point.x = Player.PointX(laser)
No condition: Action: Laser starting point.y = Player.PointY(laser)

No, that’s not what I said. I said to calculate the contact points first, then draw the laser, rather than the other way round. I made no mention of the laser following the player.

There is no need for the extra position variables, @ilary27 is already using the user defined points on the cecchino object when drawing the laser :

I followed your advice and canceled “contact” which in fact was not needed but I still have this problem on the movement … when the player is stopped everything works correctly.
as soon as the player moves laserdrawer cannot keep up with him.

Does the player’s position get changed after the laser is drawn? If so, do the player positioning events first, and then the laser events.

1 Like

thank you boys
I was able to solve the problem … I had inserted everything in a sub event and it was unable to quickly manage a movement of the player.
it was enough to pull out the code used in the photo from the sub event and now the drawing is created in the right place