Game Development Community

Laser effect

by Darren Stuart · in Torque Game Builder · 04/08/2005 (3:30 pm) · 38 replies

I want to create a decent looking laser beam.

I am going to attach an effect to a sprite and cover it.


but i can't seem to create a desent looking laser burst. I want it to look blue.

any ideas how to create one?

Cheers Guys
Page «Previous 1 2
#1
04/08/2005 (5:10 pm)
I'd start with a decent looking base sprite, then emit some blue particles during its path. That's how my laser effects will work.
#2
04/09/2005 (4:51 am)
My base sprite looks ok but I want it to glow with an energy field around it.


guess I'll just have to play around with it some more.
#3
04/09/2005 (9:18 am)
If we had masking, you could create a subtle blue beam (if the background is dark, use transparent dark blue), then mask an opaque moving/animating blue smoke texture over the beam area. That'd look nice, I think :). Maybe it's possible in the current engine, but I don't know it well enough.

But if you have a look in mind, if you post a small image of what you have as a laser right now, I could help more. I can't help with the scripting side, but I've done my fair share of art.
#4
04/11/2005 (1:36 pm)
So, things like thunder/blitz cannot be made with the actual Torque2D?
#5
04/11/2005 (10:25 pm)
You mean lightning? If you do, yes of course it can be done, in many ways.
#6
04/12/2005 (3:37 am)
Hu? I'd like to make lightning effects between two points.
I cannot find how to define a second point to make the lightning apear between the two points...
I thougt that it was like making a multi-cut laser...
(sorry for my poor english)
#7
04/12/2005 (8:15 am)
Ah, I see. You want to create a particle effect that stretches from point A to point B. I don't know much about scripting. Can anyone help Mr Lamotte?
#8
04/12/2005 (2:28 pm)
I have still not sussed this out guys. still trying

if you suss out how to do lighting this might be a good start.
#9
04/12/2005 (11:07 pm)
The particle engine definitely wouldn't be good for lightning, use an animated sprite and through some particle effects on it possibly.

Using particles only for the lightning won't provide any realistic, or good looking in my opinion, results as far as I can see.
#10
04/13/2005 (12:54 am)
That's what I think too. But I think his main issue is making an effect go from point A to point B. Maybe this should be moved to the scripting forums.
#11
04/13/2005 (1:18 am)
Sorry I don't know enough TorqueScript to show the code, but I have the logic down.

You would obviously know either Point A or Point B, prob. both.
Find which is the "higher" of the two on the Y scale.
Place the sprite at the midpoint between the two points and rotate accordingly, based on some trig. w/ the 2 points.
#12
04/13/2005 (1:57 am)
What about an invisible sprite with some particles mounted to it? Just fire the sprite between the two points.
#13
04/13/2005 (2:30 am)
To create the "grav" demo beam effect, I placed the effect at the mid-point between point A and B and rotated it accordingly as suggested above. I also set the emission to be "lineX".

Any/all of the effect/emitter(s) properties can also be changed in realtime as well, depending on the effect you want.

- Melv.
#14
04/13/2005 (2:50 am)
Here's a quick example of placing a one-pixel sprite at the midpoint between two vectors and orienting its angle to correspond to the angle between the two points.

function beam(%shooter, %target) {
	if (!isObject($beam))
		$beam = new fxStaticSprite2D() {scenegraph = t2dSceneGraph;};
	$beam.setImageMap(redPixelImageMap);

	%difference = vectorSub2D(%target.getPosition(), %shooter.getPosition());
	%sum = vectorAdd2D(%target.getPosition(), %shooter.getPosition());
	%midpoint = vectorScale2D(%sum, 0.5);
	%angle = mRadToDeg(mAtan(getWord(%difference, 0), getWord(%difference, 1)));

	$beam.setPosition(%midpoint);
	$beam.setSize("0.5" SPC vectorLength2D(%difference));
	$beam.setRotation(-%angle);
}

Keep updating that when either the shooter or the target moves.
Of course, fancier effects than the examples below are possible ;-)

www.iki.his.se/~a02hansj/beam1.png
www.iki.his.se/~a02hansj/beam2.png
#15
04/13/2005 (5:15 am)
Cool stuff Hans, that would be a quick way to draw lines and circles with the existing sdk. I don't know how efficient it will be but it will do for now!

It should be possible to use a pure white image and recolour it to any colour you desire, although I'm yet to experiment fully with this.
#16
04/13/2005 (3:43 pm)
OK than if i wand to have glowing effect aroud my lightnings, i have to add shader in its render...

You cannot make a channel of particules with the particule editor? It could be a solution to do it?
#17
04/13/2005 (4:24 pm)
I'm not sure if it's entirely what you're looking for, but you could simulate a glow with a white cloud-like sprite. Set the blend color to be whatever color and translucency you want for the glow, size and rotate it to line up with the laser size and rotation, and then use setBlending() to set the blend mode to SRC_ALPHA, ONE, the same blend mode you get from checking "Intense particles?" in the particle editor.
#18
04/13/2005 (4:36 pm)
You can create a particle emmitter along a line, so why not create a long emmiter along the length of the beam and emit "glowing" particles with a very low force and perhaps some random motion?
#19
04/22/2005 (8:32 pm)
Using Hans method, you could also use a 1x4 or 1x8 sprite and have the alpha gradualy fade to transparent(if your using PNGs for your artwork). The ends wouldn't look great, but you could fix that by attaching an "end-cap" sprite to either end.

I'm half asleep right now, maybe I'll whip up a quick demo of what I'm talking about tomorrow though.
#20
04/23/2005 (12:37 am)
That's a cool idea Joshua.
I've been looking at better ways of drawing lines, curves and other drawing primitives. I might have an update sometime in the future about that.
Page «Previous 1 2