Jump to content

Ribbons as laserbeams - alternatives?


Toumal
 Share

Recommended Posts

Hey everyone!


I'm trying to use ribbons attached to projectiles as laserbeams. This kinda sorta works, but I'm not entirely happy with it as there are some side effects.


Most visibly of all, I'm trying to have a whole bunch of projectiles shoot out from a location in a random pattern, and I'm attaching ribbons to those projectiles. This works okay, but the ribbons only start showing up at a certain distance from the projectile origin point. Since I want the appearance of laser beams, the projectiles have to be quite fast. The faster the projectile, the longer the distance until the ribbon shows up:


 

for (%i = 0; %i < 30; %i++) 
   {
      %matrix = "";
      for(%j = 0; %j < 3; %j++) 
      {
         %matrix = %matrix @ (getRandom() - 0.5) * 2 * 3.1415926 @ " ";
      }
      %mat = MatrixCreateFromEuler(%matrix);
      %vec = "0.1 0.1 0.1";
      %projectile = BulletProjectile;
      %muzzleVector = MatrixMulVector(%mat, %vec);
      %muzzleVelocity = VectorScale(%muzzleVector, %projectile.muzzleVelocity);
 
      %p = new (Projectile)()
      {
         dataBlock = %projectile;
         initialVelocity = %muzzleVelocity;
         initialPosition = %position;
      };
      MissionCleanup.add(%p);
      %ribbon = createRibbon(%proj.client.team.weapontrail, %position);
      %p.mountObject(%ribbon, 0);

 

I can't for the life of me take a screenshot as the ribbon rendering appears to be heavily FPS dependent, and any time I activate anything in terms of video recording or screenshots they simply disappear completely.


Is there anything I can do to fix this? Or should I just stay away from ribbons for laser effects? Is there a good beam resource that works for the current Torque3D version? (All the links I found are dead...)

Link to comment
Share on other sites

Hmm I dunno. It seems I don't even get the update for the first tick, apparently the server has to process that before the client even becomes aware of the new projectile, respectively the ribbon.


Right now I'm pondering just doing raycasts and rendering something in the path of that raycast. I dunno if I'll need an engine modification. Let's hope I don't need to, it's been almost 10 years since I worked with the torque engine source.


If anyone has any super easy solutions that just work, please do let me know. I'd appreciate the help ^^



EDIT: Another thing I could do is to have the laser effect happen entirely on the client side. I'd just need to send a command to all clients to initiate this. However, I don't know what the overhead is for that, and if that's affecting gameplay...



EDIT2: Ok I think clientside is probably the best way to go for the visual effect, as it doesn't have to align 100% with the projectile it's attached to. However, I can't get the ribbons to show up. Is there anything I need to do for clientside ribbons? Right now I'm attaching them to another projectile I'm creating on the client side, is that problematic too?

Link to comment
Share on other sites

I'm pretty sure this is an issue with the Projectile objects themselves only being ghosted after a short time interval, after which they've already travelled some distance. I'm not sure what the ideal solution looks like here. Creating objects on the client-side is probably a good idea, but Torque has always had issues with that due to its always-networked nature.

Link to comment
Share on other sites

Getting lag on ribbons following projectiles? Create the ribbon first. Here's some of my last game's script.

 

//.......
     if(isObject(%ribbontype))
        %ribbon = createRibbon(%ribbontype, %obj.getMuzzlePoint(%slot));
     else
        %ribbon = 0;

     //spawn that projectile  
     %p = new (%this.projectileType)()
     {
        dataBlock = %projectile;//now from above
        initialVelocity = %muzzleVelocity;
        initialPosition = %obj.getMuzzlePoint(%slot);
        sourceObject = %obj;
        sourceSlot = %slot;
        client = %obj.client;
        firedBy = %name;
        ribbon = %ribbon;
     };
     MissionCleanup.add(%p);

     if(%ribbon)
        %p.mountObject(%ribbon, 0);
     return %p;

Link to comment
Share on other sites

Thanks for your hint Steve! Unfortunately this doesn't change a thing about the way the engine handles ghosting of the ribbons. To be sure I tried your way and nothing changed.


Also I see that you set a "ribbon" field on your projectile, which does nothing functionally because the projectile class has no ribbon field.


I tried adding a ribbon field to the projectile class, but since ribbons are still subject to the standard client/server mechanisms in torque nothing changed either, except for me no longer needing to do mountObject.


Right now I'm looking at fritz' multiNodeLaserBeam which I kinda sorta got to work on the latest version of the T3D engine code, however the whole game appears to be freezing at random when I use my own compiled engine.


So yeah. A lot of work and failed experimentation for a simple visual effect so far...

Link to comment
Share on other sites

Ah, it's an issue with ghosting the ribbons themselves, not the projectiles. That's tricky. You can't always ghost the full length of the ribbon, because the client might be seeing the ribbon significantly later than its original starting time.


I'm going to see if I can fix this by sending some of the ribbon's original points to the client when it's first ghosted.


EDIT: I can't replicate this effect locally - how fast are your projectiles? I've set them to 5000 and the ribbon still gets attached to the muzzle. Though this is local-only, and I imagine the situation will be very different when tested over a network. I'll do that tonight when I get my laptop back.


EDIT: okay, easy to replicate using two instances on the same machine. Realised that my proposed fix won't work because ribbons themselves don't ghost - they're created client-side by the ribbon node. Hmm.

Link to comment
Share on other sites

Don't really have time to go into specifics atm, and tear *just* the laser-alts out but https://github.com/Azaezel/Torque3D/tree/laser has production code versions of


http://www.garagegames.com/community/resources/view/8006 +

http://www.garagegames.com/community/blogs/view/6778 +

variations on expolosion timing + ricochets (call explosion audio/visual code via a spark entry. no script callback. too spammy) + a damage interval entry so that projectiles can tick more than once. (EDIT: and per projectile lifetimes for the laser in particular to allow for stuff like charging it up.)


Will try and find time to explain any points that confuse, but no guarantees.

Link to comment
Share on other sites

  • 2 months later...

I am currently working on getting laser projectiles working. I ran into a problem of spawning a TSStatic from the muzzle with the proper rotation. I was able to get the horizontal and vertical vector components but couldn't find a way to combine the individual rotations. Instead I switched to a rather hacked solution by spawning a projectile with a very low velocity, overriding the normal damage with a raycast so the player can't kill himself, and scaling the projectile in the Y-Axis to the hit location of the raycast. This works fine for now but I'm going to try with the previous method, if anybody can point me in the right direction of combining rotations I'd be grateful. Ex. "0 0 1 90" + "1 1 0 50", etc.


Horizontal Component

http://imagizer.imageshack.com/img633/7943/kQqFd7.th.png


Vertical Component

http://imagizer.imageshack.com/img907/1864/EDn5FW.th.png


Here is a video of the latter method with the projectile moving very slowly:

LZ09ij4-wLo

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...