Creating a continuous projectile/ghost trail
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
- Jekyll Grim Payne
- Global Moderator
- Posts: 1120
- Joined: Mon Jul 21, 2008 4:08 am
- Preferred Pronouns: He/Him
- Graphics Processor: nVidia (Modern GZDoom)
- Contact:
Creating a continuous projectile/ghost trail
Hi, all.
The simples way to make a trail is to make a projectile (or some ghost-looking monster, etc.) spawn its translucent immovable twins that would fade out behind it, creating a trail. But if the projectile is too fast, the pieces of the trail will have large spaces between each other, which can be easily seen if we look at the trail from the side.
The thing is, I think I saw somewhere in Wiki a method to spawn more than 1 trail piece per tic which would create a continuous trail even for fast projectiles. Is there a way actually? I think it was somehow connected to Hexen's Mage wand missile (MageWandMissile), but now looking at its code I can't get it.
The simples way to make a trail is to make a projectile (or some ghost-looking monster, etc.) spawn its translucent immovable twins that would fade out behind it, creating a trail. But if the projectile is too fast, the pieces of the trail will have large spaces between each other, which can be easily seen if we look at the trail from the side.
The thing is, I think I saw somewhere in Wiki a method to spawn more than 1 trail piece per tic which would create a continuous trail even for fast projectiles. Is there a way actually? I think it was somehow connected to Hexen's Mage wand missile (MageWandMissile), but now looking at its code I can't get it.
Re: Creating a continuous projectile/ghost trail
Inherit from the FastProjectile class and set its MissileType parameter to what you want the trail to be. Normally, these trails spawn too low, so the best thing to do is to set MissileType to a "TrailSpawner" item that uses A_SpawnItemEx to stick the object at the correct height (exactly half the projectile's height will do it -- 8 units generally). Using A_SpawnItemEx here also has the advantage of allowing for slight randomization of position, which looks great on smoke trails.
There was some talk at some point about adding a 'height' parameter so you can specify this without having to spawn an interim actor, but I can't remember if this got in or what it's called if it did.
There was some talk at some point about adding a 'height' parameter so you can specify this without having to spawn an interim actor, but I can't remember if this got in or what it's called if it did.

- NeuralStunner
-
- Posts: 12328
- Joined: Tue Jul 21, 2009 12:04 pm
- Preferred Pronouns: No Preference
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia with Vulkan support
- Location: capital N, capital S, no space
- Contact:
Re: Creating a continuous projectile/ghost trail
It was added already, it uses the FP's MissileHeight.Xaser wrote:There was some talk at some point about adding a 'height' parameter so you can specify this without having to spawn an interim actor, but I can't remember if this got in or what it's called if it did.

- Jekyll Grim Payne
- Global Moderator
- Posts: 1120
- Joined: Mon Jul 21, 2008 4:08 am
- Preferred Pronouns: He/Him
- Graphics Processor: nVidia (Modern GZDoom)
- Contact:
Re: Creating a continuous projectile/ghost trail
Sounds great, but how do I actually specify the frequency of the spawning of trail pieces? Because I may need to increase or decrease it according to the speed of my fastprojectile.
- NeuralStunner
-
- Posts: 12328
- Joined: Tue Jul 21, 2009 12:04 pm
- Preferred Pronouns: No Preference
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia with Vulkan support
- Location: capital N, capital S, no space
- Contact:
Re: Creating a continuous projectile/ghost trail
Well, the way I understand it, a FP works by "slicing" the distance into several steps based on the radius of the projectile. Smaller, faster actors use more steps than larger, slower ones. It uses simpler collision checks so this doesn't bog down the system. I guess it spawns a trail actor for each of these steps.
I have discussed using a property to define how many steps to skip between trail spawning, I don't think I put up a suggestion thread for it yet. (MinMissileChance might be an OK property name to borrow.)
I.E. MinMissileChance 4
This would spawn a trail actor every 4th movement step. If that sounds good, go ahead and post a feature suggestion if you like.
I have discussed using a property to define how many steps to skip between trail spawning, I don't think I put up a suggestion thread for it yet. (MinMissileChance might be an OK property name to borrow.)
I.E. MinMissileChance 4
This would spawn a trail actor every 4th movement step. If that sounds good, go ahead and post a feature suggestion if you like.

- Jekyll Grim Payne
- Global Moderator
- Posts: 1120
- Joined: Mon Jul 21, 2008 4:08 am
- Preferred Pronouns: He/Him
- Graphics Processor: nVidia (Modern GZDoom)
- Contact:
Re: Creating a continuous projectile/ghost trail
Well, yeah, maybe... but as there isn't such property yet, HOW do I control it? Simply by adjusting the FP's size and speed?
- NeuralStunner
-
- Posts: 12328
- Joined: Tue Jul 21, 2009 12:04 pm
- Preferred Pronouns: No Preference
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia with Vulkan support
- Location: capital N, capital S, no space
- Contact:
Re: Creating a continuous projectile/ghost trail
Well... You could use a jump to make the trail actors immediately stop and vanish. This could be random, or you could have the trail actor an ACS script that returns whether to become visible or not, and increment a counter each time. But that'd be hell to set up for sucha simple effect. 
Although, check whether the trail actors take the projectile as their Target... That would make it a lot simpler.

Although, check whether the trail actors take the projectile as their Target... That would make it a lot simpler.
- Jekyll Grim Payne
- Global Moderator
- Posts: 1120
- Joined: Mon Jul 21, 2008 4:08 am
- Preferred Pronouns: He/Him
- Graphics Processor: nVidia (Modern GZDoom)
- Contact:
Re: Creating a continuous projectile/ghost trail
Code: Select all
Actor RicochetBullet : FastProjectile
{
+MISSILE
+NOBLOCKMAP
+NOGRAVITY
+DROPOFF
+NOTELEPORT
+FORCEXYBILLBOARD
+HEXENBOUNCE
mass 1
damage 0
radius 3
height 3
speed 30
seesound "weapons/ricochet"
renderstyle TRANSLUCENT
alpha 0.8
translation "0:255=160:163"
scale .25
MissileType BulletTrail
MissileHeight 2
states
{
Spawn:
PUFF A 1 bright A_FadeOut(0.2)
wait
}
}
It looks not bad, though, but not perfect... Also this is not suitable for an idea I had, which was a realistic laser sight.
- InsanityBringer
- Posts: 3392
- Joined: Thu Jul 05, 2007 4:53 pm
- Location: opening the forbidden box
Re: Creating a continuous projectile/ghost trail
If you're looking for constant beams, I got some code that might be able to help
I haven't prepared a releasable sample of it, but if it fits your needs I'll whip one up.
It won't help your projectile (you know, it could be adapted to that though), but it should be adaptable to make a laser sight.
I haven't prepared a releasable sample of it, but if it fits your needs I'll whip one up.
It won't help your projectile (you know, it could be adapted to that though), but it should be adaptable to make a laser sight.
- Jekyll Grim Payne
- Global Moderator
- Posts: 1120
- Joined: Mon Jul 21, 2008 4:08 am
- Preferred Pronouns: He/Him
- Graphics Processor: nVidia (Modern GZDoom)
- Contact:
Re: Creating a continuous projectile/ghost trail
Beam, that's the word. I somehow forgot about it 
Looks great, so what's the code? I only need to know the functions and properties, etc.,I'll be able to adapt it all right.

Looks great, so what's the code? I only need to know the functions and properties, etc.,I'll be able to adapt it all right.
- InsanityBringer
- Posts: 3392
- Joined: Thu Jul 05, 2007 4:53 pm
- Location: opening the forbidden box
Re: Creating a continuous projectile/ghost trail
Here's the code: http://basementnet.us/ryan/BlasterPistol.zip
The pistol is on slot 8, and the laser attack is the altfire. On the implementation side, script 949 does all of the magic, included in LASERDRW (the laser drawing library), the source is included in the WAD. Script 949 must be called by a hitscan's puff, and the range of said hitscan must be limited to 1024 units. If you need it to be longer, it should be easy to modify the script to make it work for longer hitscans. (if it's longer, nothing weird should happen, but the laser will end aruptly)
The pistol is on slot 8, and the laser attack is the altfire. On the implementation side, script 949 does all of the magic, included in LASERDRW (the laser drawing library), the source is included in the WAD. Script 949 must be called by a hitscan's puff, and the range of said hitscan must be limited to 1024 units. If you need it to be longer, it should be easy to modify the script to make it work for longer hitscans. (if it's longer, nothing weird should happen, but the laser will end aruptly)
- Jekyll Grim Payne
- Global Moderator
- Posts: 1120
- Joined: Mon Jul 21, 2008 4:08 am
- Preferred Pronouns: He/Him
- Graphics Processor: nVidia (Modern GZDoom)
- Contact:
Re: Creating a continuous projectile/ghost trail
Ugh, lots of ACS... which I barely understand. Thanks for sharing, though I doubt I'm going to use that just for my ricochet. And I'm not making any laser sights at the moment, so... maybe later.