Torque Laser Beams
by Robert Brower · 03/01/2003 (4:44 pm) · 56 comments
Download Code File
Instructions for adding beams to your Torque Game Engine are in the readme.txt file.
As always, if you have any questions or problems, or if you've found some nice way to improve upon this, then please make comments here so we can all benefit from them. Thank you!
Robert & Hugh
Removed beamLength from datablock. I didn't want to do this but beams should work multiplayer now.
Instructions for adding beams to your Torque Game Engine are in the readme.txt file.
As always, if you have any questions or problems, or if you've found some nice way to improve upon this, then please make comments here so we can all benefit from them. Thank you!
Robert & Hugh
Removed beamLength from datablock. I didn't want to do this but beams should work multiplayer now.
About the author
#2
edit- im getting thousands of this warning on compile.
c:\torque\engine\console\consoletypes.h(11) : warning C4005: 'Offset' : macro redefinition
c:\torque\engine\platform\event.h(14) : see previous definition of 'Offset'
03/01/2003 (5:30 pm)
WOOOOHOOOOO yees Thankyou! beam weaponry is su much funner to zap people with.edit- im getting thousands of this warning on compile.
c:\torque\engine\console\consoletypes.h(11) : warning C4005: 'Offset' : macro redefinition
c:\torque\engine\platform\event.h(14) : see previous definition of 'Offset'
#3
03/02/2003 (5:07 am)
This is very cool. I didn't have any problems adding the code, but it doesn't seem to render the beam on network connections. Works fine on a single game.
#4
03/02/2003 (8:17 am)
As it turns out, 250 ms lifetime is not long enough for other players to see the beam. Try setting the lifetime of the beam to 500ms. Let me know if that works for you. As for compile errors, I'm not sure whats going on there except to say that console/consoleTypes.h requires some care when adding the TypeBeamDataPtr. Make sure you don't use my file, just use the line of code I added and add it to yours. Good luck.
#5
03/02/2003 (2:00 pm)
I tried 500 and 1000 but it still doesn't seem to work on client connections. Does it show up ok for you?
#6
03/02/2003 (4:23 pm)
OK, i didn't want to do it but I removed beamLength from the datablock. It should work multiplayer now. I tested it here. The other way worked too, but I guess not in all configurations like I had hoped. Files changed: beam.h, beam.cc, laserbeam.cs. Good luck.
#7
Thanks very much for this resource. It's a great thing to have.
03/03/2003 (3:05 am)
Works multiplayer now! That's too bad the beamLength wouldn't always work. Maybe if some people aren't using multiplayer they can use the first version.Thanks very much for this resource. It's a great thing to have.
#8
03/03/2003 (1:40 pm)
I have a small problem here, Whenever I try to pickup the weapon by having the player walk up to it the player just goes right on through it. Do I have to define the new beam weapon in the inventory system somehow in order for the player to be able to pick it up?
#9
03/03/2003 (1:42 pm)
It worked despite any warning i was getting during compile. It was the same prob over and over so it probably isnt critical. It works great! Im going to integrate the new changed files today, Thanks alot.
#10
03/03/2003 (1:43 pm)
Nathan: you need to edit the player.cs maxInv(LaserBeam) =[1]; to pick it up
#11
maxInv[LaserBeam] = 1;
:)
03/03/2003 (2:05 pm)
Ahh thank you Tim. By the way the actual line should be:maxInv[LaserBeam] = 1;
:)
#12
to the player in the readme.txt file.
03/03/2003 (3:13 pm)
Thanks guys, I missed the part about adding maxInv[LaserBeam] = 1;to the player in the readme.txt file.
#14
I've done this successfully with our project in both multiplayer and single player.
Even without the hardcoded parameter the effect is exactly the same, if not a little trickier to reproduce.
Well done.
06/17/2003 (9:12 pm)
FYI, if it isn't blatenly obvious, the same effect as the beamLength can by making a small computation of muzzelVelocity and lifeTime.I've done this successfully with our project in both multiplayer and single player.
Even without the hardcoded parameter the effect is exactly the same, if not a little trickier to reproduce.
Well done.
#15
07/06/2003 (9:06 am)
I still can't get this to work in multiplayer, can anyone help
#16
G:\torque\engine\game\beam.cc(29) : error C2065: 'ForceFieldObjectType' : undeclared identifier
i went through the script files to comment out the particle and explosion functions but i still get this error. can anyone help? thanks chris
07/24/2003 (3:08 pm)
i get an error G:\torque\engine\game\beam.cc(29) : error C2065: 'ForceFieldObjectType' : undeclared identifier
i went through the script files to comment out the particle and explosion functions but i still get this error. can anyone help? thanks chris
#17
Look for ForceFieldObjectType in all of the engine source code files. I think it is in objectTypes.h. It is probably no longer used in the version of the engine code that you have and you might just remove it from the code and it may work.
Anthony, did you ever get them to work in multiplayer?
Robert
07/26/2003 (10:33 am)
Chris,Look for ForceFieldObjectType in all of the engine source code files. I think it is in objectTypes.h. It is probably no longer used in the version of the engine code that you have and you might just remove it from the code and it may work.
Anthony, did you ever get them to work in multiplayer?
Robert
#18
07/31/2003 (5:50 pm)
Robert i deleted all the references to ForceFieldObjectType, i also went through the scripts and the laser still doesn't work. the player wont even pick it up. if you know what is wrong please let me know. thanks chris
#19
// RFB ->
// Is Object Rendered?
if (state->isObjectRendered(this))
{
// Yes, so get a SceneRenderImage.
SceneRenderImage* image = new SceneRenderImage;
// Populate it.
image->obj = this;
image->isTranslucent = true;
image->sortType = SceneRenderImage::BeginSort;
// Insert it into the scene images.
state->insertRenderImage(image);
// Yes, so get a SceneRenderImage.
image = new SceneRenderImage;
// Populate it.
image->obj = this;
image->isTranslucent = true;
image->sortType = SceneRenderImage::EndSort;
// Insert it into the scene images.
state->insertRenderImage(image);
}
return false;
// <- RFB
Hope it makes your beams better. Enjoy... Robert
10/02/2003 (1:49 pm)
Posting a small update to the resource into this comment now. Normal projectiles are not zone managed because they are typcially small objects that can only ever appear in one zone at a time. This is not the case for beam like weapons as the beams may extend from one zone into another. So... using fxSunlight as an example of how to prep a render image, I made the following changes to Beam::prepRenderImage().... check it out... You'll find that the beams now render more consistently than ever.// RFB ->
// Is Object Rendered?
if (state->isObjectRendered(this))
{
// Yes, so get a SceneRenderImage.
SceneRenderImage* image = new SceneRenderImage;
// Populate it.
image->obj = this;
image->isTranslucent = true;
image->sortType = SceneRenderImage::BeginSort;
// Insert it into the scene images.
state->insertRenderImage(image);
// Yes, so get a SceneRenderImage.
image = new SceneRenderImage;
// Populate it.
image->obj = this;
image->isTranslucent = true;
image->sortType = SceneRenderImage::EndSort;
// Insert it into the scene images.
state->insertRenderImage(image);
}
return false;
// <- RFB
Hope it makes your beams better. Enjoy... Robert
#20
11/03/2003 (6:51 pm)
I haven't tried this yet, but I'm stoked someone has done it! (and a flashlight to boot!) ... I've been thinking of how to code this myself and well, I'm sure this will save me days worth of effort. Thanks Robert!
Torque 3D Owner Jeff Wilkinson