in my game I’m working on a weapon that shoots a continuous lazer, and I’m wondering if i could have a way that the player could see a thin line showing where the lazer will go before they shoot. I wouldn’t want to use an emitter because that would probably lag my game too much and I’m pretty sure you cant make raycasts visible.
https://flowlab.io/game/play/1416959
Tried a line object? 1 or 2 pixels high and long.
You can stretch/scale the line to lengthen it.
I did something similar here
https://flowlab.io/game/play/1422549
The line is stretched by scaling only X.
Ignore the mess in there, playing around with vectors. ‘Draw Line P1 P2’ is the bundle that does the work.
And why am I only using half a line? Now that’s a completely different story
Probably too complicated for your case, you’ll be fine with just a simple line.
@todorrobot could use it to make a real 3D Laser Dave :bleep_bloop:
lemme see if I can start it up on my vintage PC to have a look
so you want to attach the line to the gun?
ah, I see, you used my bundle as is. Needs to be changed to suit your case @F3Art , I have a look.
I guess it should follow the muse pointer as target?
The bundle I used is the starting point for a vector line drawing engine, I just showed it so you can see what single line object looks like in action.
off to play
You only need a line attached to your gun. If you look into my example have a look at the line. Attachment attach the center. That’s why the line is drawn at full length and then you will see that I have one animation frame where it is only half the length. I switch to that so it looks like it only goes one way.
First impression ( I might be wrong ). attach line to gun, switch to ‘half’ view, make sure rotation lines up with gun.
Hmmm, the gun should automatically point to the mouse? Not only after you click? Otherwise what sense would the laser sight make
Ok, here what I got… dang, looking through your code is like walking through a mine field @F3Art … organize, bundle, bundle …
-
create a ‘half’ animation frame for your line:
-
remove all you had in behaviors there and put this in:
-
add this to your laser gun:
and you get this:
I changed the display level of the gun to 2 and left the line on 1, so the gun shows up on top. Also, you might wanna replace the fixed scale with an equation that adjusts the length so it nearly hits the map boundaries.
Does this help?
@TinkerSmith yes thank you! i actually didn’t see that last comment until just now so I did some stuff that’s similar to that beforehand, only thing is what you just said is way simpler. I just kept making the sprite bigger instead of just using the size block and i was still using most of your original bundle.
I never would have been able to do this without your help!
Ok, I’m nice today, it’s Sunday.
Here the ‘auto adjust’ routine:
If you change the line length you have to adjust here:
And I saved the code here: (was too long for here)
http://flowlabing.wikidot.com/bundles:5
Have fun
New Zealand … that’s why I am way ahead of you all MUAHAHA
P.S. maybe add some transparency to the laser line, makes it look more real.
You could also play around with the color filter bundle to make it sort of pulsating.
@TinkerSmith I have the line at 50% alpha now.
I haven’t really used the colour block all that much but that would be really cool.
your flowlab wiki is pretty cool by the way. I saw your forum post about it but I haven’t checked it out until now.
@F3Art
Is work in progress. I might put more work into it if the interest raises.
But thanks that you like it so far
P.S. looks really laser like now