Page 1 of 1

vertical alignment of fireball trails

Posted: Sat Mar 21, 2009 3:12 pm
by Anakin S.
I used A_SpawnItem to spawn sprites behind a fast projectile. It works fine except for when you shoot up or down. Then it looks like a bunch of steps. Is there a way to get it to be a continuous incline? So far, I replaced the vertical displacement by momz, but I think it's probably more complicated than that. So far this doesn't behave any differently from before.

Code: Select all

FX03 B 0 bright A_SpawnItem("KineticTrail", 1, momz, 0)
FX03 B 0 bright A_SpawnItem("KineticTrail", 3, momz, 0)
FX03 B 0 bright A_SpawnItem("KineticTrail", 5, momz, 0)
FX03 B 0 bright A_SpawnItem("KineticTrail", 7, momz, 0)
FX03 B 0 bright A_SpawnItem("KineticTrail", 9, momz, 0)
FX03 B 0 bright A_SpawnItem("KineticTrail", 11, momz, 0)
FX03 B 0 bright A_SpawnItem("KineticTrail", 13, momz, 0)
FX03 B 0 bright A_SpawnItem("KineticTrail", 15, momz, 0)
FX03 B 1 bright A_SpawnItem("KineticTrail", 17, momz, 0)
Loop

Re: vertical alignment of fireball trails

Posted: Sat Mar 21, 2009 4:34 pm
by MG_Man
Zpos is the vertical height, not the vertical speed. Use the 'x offset' parameter for distance, and '0' for z-momentum. I don't know if momz will work for that, I haven't really messed with this sort of thing.

To do vertical speed, you'll have to use A_SpawnItemEx.

Re: vertical alignment of fireball trails

Posted: Sat Mar 21, 2009 5:13 pm
by Anakin S.
Thanks. I just realized that I need to make the vertical displacement of each sprite a function of the vertical momentum or whatever variable it is. Is it possible to write an expression for an argument of a decorate action?

Re: vertical alignment of fireball trails

Posted: Sat Mar 21, 2009 8:34 pm
by Ghastly
The closest I've ever gotten to this is this: http://forum.zdoom.org/viewtopic.php?f=3&t=20766. As you can see in the thread, though, it has some problems.

Re: vertical alignment of fireball trails

Posted: Sun Mar 22, 2009 2:44 pm
by Anakin S.
I have the same issue now too. When I fire it from one angle, it works perfectly if I aim up or down or horizontally. However, if I move left and right of that or 180 degrees, the trails end up facing the wrong way.

So when fired straight north (or whichever direction it is), the trail is perpendicular to the path of the projectile. That angle between travel path and trail decreases as you move closer to the west and increases as you move closer to the east. When you're facing directly west, it's perfect. The projectile moves west and the trail is right behind it. When you're facing east, however, it's the opposite. It's as if the trail sprites have a fixed position in space that doesn't take the facing angle into account at all.

That makes me wonder what exactly momx, momy, and momz really are. Are they really just the x, y, and z components of the speed vector? Do they take into account the actor's facing angle?

Here's what I have right now:

Code: Select all

FX03 B 0 bright A_SpawnItemEx("KineticTrail", -(momx/12), -(momy/12), -1*(momz - 10*(momz/12)), 0, 0, 0, 0, 1, 0)
FX03 B 0 bright A_SpawnItemEx("KineticTrail", -2*(momx/12), -2*(momy/12), -1*(momz - 9*(momz/12)), 0, 0, 0, 0, 1, 0)
FX03 B 0 bright A_SpawnItemEx("KineticTrail", -3*(momx/12), -3*(momy/12), -1*(momz - 8*(momz/12)), 0, 0, 0, 0, 1, 0)
FX03 B 0 bright A_SpawnItemEx("KineticTrail", -4*(momx/12), -4*(momy/12), -1*(momz - 7*(momz/12)), 0, 0, 0, 0, 1, 0)
FX03 B 0 bright A_SpawnItemEx("KineticTrail", -5*(momx/12), -5*(momy/12), -1*(momz - 6*(momz/12)), 0, 0, 0, 0, 1, 0)
FX03 B 0 bright A_SpawnItemEx("KineticTrail", -6*(momx/12), -6*(momy/12), -1*(momz - 5*(momz/12)), 0, 0, 0, 0, 1, 0)
FX03 B 0 bright A_SpawnItemEx("KineticTrail", -7*(momx/12), -7*(momy/12), -1*(momz - 4*(momz/12)), 0, 0, 0, 0, 1, 0)
FX03 B 0 bright A_SpawnItemEx("KineticTrail", -8*(momx/12), -8*(momy/12), -1*(momz - 3*(momz/12)), 0, 0, 0, 0, 1, 0)
FX03 B 0 bright A_SpawnItemEx("KineticTrail", -9*(momx/12), -9*(momy/12), -1*(momz - 2*(momz/12)), 0, 0, 0, 0, 1, 0)
FX03 B 1 bright A_SpawnItemEx("KineticTrail", -10*(momx/12), -10*(momy/12), -1*(momz - 1*(momz/12)), 0, 0, 0, 0, 1, 0)

Re: vertical alignment of fireball trails

Posted: Sun Mar 22, 2009 4:05 pm
by Ghastly
Anakin S. wrote:That makes me wonder what exactly momx, momy, and momz really are. Are they really just the x, y, and z components of the speed vector? Do they take into account the actor's facing angle?
Unless you're using the A_SpawnItemEx Absolute Momentum flag, they take map compass direction as momentum. I used the projectile's speed as a base, for the X momentum, when I tried.

Re: vertical alignment of fireball trails

Posted: Sun Mar 22, 2009 5:59 pm
by Anakin S.
Can we use trig functions?

Re: vertical alignment of fireball trails

Posted: Mon Mar 23, 2009 6:04 pm
by Anakin S.
I got it to work! I don't know exactly what the problem was, but it was fixed by putting -angle in the angle parameter. I also had to put on absolute position and absolute momentum (10).

Re: vertical alignment of fireball trails

Posted: Mon Mar 23, 2009 6:29 pm
by MG_Man
Damn! Sorry if I say this, but you MUST post the WAD of this.

This is, AFAIK, the first time ever something like this has been perfected with A_SpawnItemEx.

Re: vertical alignment of fireball trails

Posted: Mon Mar 23, 2009 7:49 pm
by Ghastly
Indeed. I've been trying on and off to get it to work for a while. Just slap together a test wad, with the DoomImpBall doing this.