Projectiles don't inherit pitch?
Projectiles don't inherit pitch?
For some reason, when a projectile is spawned it inherits its angle from it's firer, but not its pitch. This usually isn't a problem since you can't see an actors' pitch from their sprites anyways, but when you try to make 3D models for atypical projectiles, they always spawn with a centered pitch.
PITCHFROMMOMENTUM is not what I want. All that does is change the model's pitch based on what direction it's moving in the most. It doesn't reflect the actor's actual pitch. For example, let's say I want to make something like a torpedo that can strafe up/down/left/right in midair but always point in the direction you fired it in. PITCHFROMMOMENTUM would make the torpedo point all over the place, even if the actor was looking straight ahead the whole time. And this is what INHERITACTORPITCH is supposed to be useful for.
Buuuuut apperantly projectiles are always spawned with Pitch 0, regardless of what their firer's pitch is. And what i'm trying to do (3D projectiles and trails) looks like poop because of this.
PITCHFROMMOMENTUM is not what I want. All that does is change the model's pitch based on what direction it's moving in the most. It doesn't reflect the actor's actual pitch. For example, let's say I want to make something like a torpedo that can strafe up/down/left/right in midair but always point in the direction you fired it in. PITCHFROMMOMENTUM would make the torpedo point all over the place, even if the actor was looking straight ahead the whole time. And this is what INHERITACTORPITCH is supposed to be useful for.
Buuuuut apperantly projectiles are always spawned with Pitch 0, regardless of what their firer's pitch is. And what i'm trying to do (3D projectiles and trails) looks like poop because of this.
Last edited by Ænima on Thu Jan 30, 2014 7:12 pm, edited 1 time in total.
Reinforcements: midgame Survival joining/respawning
Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)

Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)

RE: Projectiles don't inherit pitch?
Just set it accordingly, using -pitch in some parameter (IDK what function to spawn them do you use).
RE: Projectiles don't inherit pitch?
Yeah, pitch doesn't inherit for any monster projectiles. I tried various ways to get around that to get true 3d fractals in monster projectiles in Fractal Doom but eventually had to settle for horizontally fractal monster projectiles, and even those were a hacky solution with projectiles that were fired at the same time as the other projectiles with the needed angles to intercept other projectiles but were +NOCLIP and +THRUACTORS and invisible until being "fired" by another projectile.
To get monster projectiles to have correct pitch you would need to have the arcsin function to set it via a_setpitch, which you don't in decorate or acs. I asked randy about it a while ago here: http://forum.zdoom.org/viewtopic.php?f= ... 6&p=690257
Since you're using it just for appearances and not to spawn anything else, I've heard A_SetPitch (sin(momz)/cos(momx)) being bandied about; it isn't at all accurate enough to spawn stuff with but might look better than the A_SetPitch(momz*2) you're using. No idea which will be better though.
If you're using this for player fired projectile , then this is an entirely different matter and you can definitely get the exact correct pitch for the trail actors. Instead of firing the initial projectile with A_FireCustomMissile fire it using
A_SpawnItemEx (<type>,cos(-pitch-[desired pitch offset--probably 0])*<Dist. from spawner>,<yoffset>,<zoffset>+(sin(-pitch-[desired pitch offset--probably 0])*<Dist. from spawner>),cos(-pitch[desired pitch offset--probably 0])*<Projectile speed>,0,sin(-pitch[desired pitch offset--probably 0])*<Projectile speed>,<angle>,SXF_TRANSFERPITCH|<other flags>,<chance>)
and then spawn the trail actors using the same formula albiet with the speed at 0.
To get monster projectiles to have correct pitch you would need to have the arcsin function to set it via a_setpitch, which you don't in decorate or acs. I asked randy about it a while ago here: http://forum.zdoom.org/viewtopic.php?f= ... 6&p=690257
Since you're using it just for appearances and not to spawn anything else, I've heard A_SetPitch (sin(momz)/cos(momx)) being bandied about; it isn't at all accurate enough to spawn stuff with but might look better than the A_SetPitch(momz*2) you're using. No idea which will be better though.
If you're using this for player fired projectile , then this is an entirely different matter and you can definitely get the exact correct pitch for the trail actors. Instead of firing the initial projectile with A_FireCustomMissile fire it using
A_SpawnItemEx (<type>,cos(-pitch-[desired pitch offset--probably 0])*<Dist. from spawner>,<yoffset>,<zoffset>+(sin(-pitch-[desired pitch offset--probably 0])*<Dist. from spawner>),cos(-pitch[desired pitch offset--probably 0])*<Projectile speed>,0,sin(-pitch[desired pitch offset--probably 0])*<Projectile speed>,<angle>,SXF_TRANSFERPITCH|<other flags>,<chance>)
and then spawn the trail actors using the same formula albiet with the speed at 0.
RE: Projectiles don't inherit pitch?
A_SpawnItem() shouldn't ever be used for projectile spawning. Besides why can't you just use "-pitch" in the pitch parameter of A_CustomMissile()?
RE: Projectiles don't inherit pitch?
ZzZombo wrote: A_SpawnItem() shouldn't ever be used for projectile spawning.
I don't understand; assuming you mean a_spawnitemex, it's great for player projectiles and does lots of stuff that can't be done otherwise.
None of the flags for A_CustomMissile will transfer an aimed pitch or the firing actor's pitch.ZzZombo wrote: Besides why can't you just use "-pitch" in the pitch parameter of A_CustomMissile()?
RE: Projectiles don't inherit pitch?
[quote=http://zdoom.org/wiki/A_CustomMissile]CMF_AIMDIRECTION
The missile is not aimed at a target. Instead, it is shot in the specified direction with the specified pitch. This is the same as putting 2 into the aimflags parameter.[/quote]What?
The missile is not aimed at a target. Instead, it is shot in the specified direction with the specified pitch. This is the same as putting 2 into the aimflags parameter.[/quote]What?
Last edited by ZzZombo on Mon Mar 03, 2014 8:24 am, edited 1 time in total.
RE: Projectiles don't inherit pitch?
Are you sure this flag exists for ZDoom 2.5.0, or even better 2.3.1 so it can be used in Zandronum? You know that Zandronum is several years late.
𝕂𝕝𝕠𝕗𝕜𝕒𝕔
RE: Projectiles don't inherit pitch?
Damn, why the fuck you think I would came here if I didn't know for sure it works?
Regarding the A_SpawnItemEx() used to spawn projectiles there even was a response from Torr Samaho clearly saying it wasn't designed with spawning of projectiles in mind.
Regarding the A_SpawnItemEx() used to spawn projectiles there even was a response from Torr Samaho clearly saying it wasn't designed with spawning of projectiles in mind.
RE: Projectiles don't inherit pitch?
Even if you put "pitch" in A_CustomMissile and use that flag to use the firing actor's pitch it will not work because a monster's pitch is always 0, and so the pitch transferred to the projectile is 0.ZzZombo wrote:What?http://zdoom.org/wiki/A_CustomMissile wrote:CMF_AIMDIRECTION
The missile is not aimed at a target. Instead, it is shot in the specified direction with the specified pitch. This is the same as putting 2 into the aimflags parameter.
Likewise if you use A_CustomMissile to fire a projectile from a projectile fired from a monster, it's still going to have a pitch of 0. So it will transfer that pitch of 0.
RE: Projectiles don't inherit pitch?
Okay, to clarify, I was thinking only about players when posting this.
RE: Projectiles don't inherit pitch?
But A_CustomMissile is a monster attack though.ZzZombo wrote: Okay, to clarify, I was thinking only about players when posting this.
RE: Projectiles don't inherit pitch?
No. It works for players just as good. Since you yourself pointed out monsters have their pitch zeroed otherwise the pitch parameter and related flags would be useless.
RE: Projectiles don't inherit pitch?
It doesn't work for players correctly. Try the replacement shotgun in this test wad which has the following decorate:ZzZombo wrote: No. It works for players just as good.
Spoiler: Decorate (Open)
Or this other test wad which has the following decorate:
Spoiler: Decorate (Open)
That flag is used to specify an absolute pitch, which replaces the aimed pitch.ZzZombo wrote: Since you yourself pointed out monsters have their pitch zeroed otherwise the pitch parameter and related flags would be useless.
ZzZombo wrote:What?http://zdoom.org/wiki/A_CustomMissile wrote:CMF_AIMDIRECTION
The missile is not aimed at a target. Instead, it is shot in the specified direction with the specified pitch. This is the same as putting 2 into the aimflags parameter.
RE: Projectiles don't inherit pitch?
A_SpawnItemEx may not have been designed for projectiles in mind, but unless Zandronum's developers have been intentionally avoiding adding changes from ZDoom, that's been changed. Projectiles correctly assign their target field to their firer, and that's basically all that's needed for a projectile to function.
Granted, you have to pull off some tricks so that it works with crouching and stuff, but it still works perfectly fine otherwise.
Granted, you have to pull off some tricks so that it works with crouching and stuff, but it still works perfectly fine otherwise.
RE: Projectiles don't inherit pitch?
of course the monters attack function for firing missiles will not work when used in a weapons DECORATE, when it is not properly supported for weapon actors ;_;
for weapons, use this for projectiles (obvious)
http://zdoom.org/wiki/A_FireCustomMissile
for monsters it does not matter, you do not have to keep track of kill, frags or the like, only thing you have to make sure of is that you can proberly imitate the behaviour of the monsters projectile attack functionality.
for weapons, use this for projectiles (obvious)
http://zdoom.org/wiki/A_FireCustomMissile
for monsters it does not matter, you do not have to keep track of kill, frags or the like, only thing you have to make sure of is that you can proberly imitate the behaviour of the monsters projectile attack functionality.
Combinebobnt wrote:i can see the forum league is taking off much better than the ctf ones
GalactusToday at 1:07 PM
are you getting uncomfortable jap
feeling something happen down there
- Dark-Assassin
- Maintenence Crew
- Posts: 968
- Joined: Fri May 25, 2012 4:25 am
RE: Projectiles don't inherit pitch?
Code: Select all
A_CustomMissile("YourChildProjectile",0,0,0,CMF_TRACKOWNER|CMF_AIMDIRECTION,(momz*6))Took me ages to find this out for one of my test projects.
To have it fire in different directions, you need to edit the 4th argument and append to the 6th one after the first bracket. It will take some getting used to.
For Reference: http://zdoom.org/wiki/A_CustomMissile
RE: Projectiles don't inherit pitch?
For player weapons a_spawnitemex is a lot better if you're looking to do anything with pitch or having it spawn other projectiles. To do what Ænima wants to do with projectiles you'll have to use it for a player weapon in this case.Lollipop wrote: of course the monters attack function for firing missiles will not work when used in a weapons DECORATE, when it is not properly supported for weapon actors ;_;
for weapons, use this for projectiles (obvious)
http://zdoom.org/wiki/A_FireCustomMissile
for monsters it does not matter, you do not have to keep track of kill, frags or the like, only thing you have to make sure of is that you can proberly imitate the behaviour of the monsters projectile attack functionality.
That's basically the same thing Ænima's already doing with his A_setpitch(momz*2), or what I suggested with A_SetPitch (sin(momz)/cos(momx)), except with a different formula.-=Dark-Assassin=- wrote:This will spawn a child projectile inheriting the pitch of the parent projectile.Code: Select all
A_CustomMissile("YourChildProjectile",0,0,0,CMF_TRACKOWNER|CMF_AIMDIRECTION,(momz*6))
Took me ages to find this out for one of my test projects.
To have it fire in different directions, you need to edit the 4th argument and append to the 6th one after the first bracket. It will take some getting used to.
For Reference: http://zdoom.org/wiki/A_CustomMissile
I have no idea which ends up being more accurate in the end, momz*6, momz*2, or sin(momz)/cos(momx), since none of them is actually the formula for getting a pitch, just an approximation.
I can graph them all later and see which most closely follows the actual pitch, but I have a sneaking suspicion that all will have a range in which they are more accurate than the others but none will be most accurate for the entire range. There is also probably a closer approximation that hasn't been listed yet, dunno what it is.
I suppose you could have jumps in decorate to have it use different pitch formulas depending upon what it's momz is, and that might be most accurate of all. I really wish arc functions were in decorate like other trig functions are. Of course since he's just using it for appearances it doesn't have to be 100% accurate.
Also, Ænima still hasn't said whether this is for monster or player projectiles, though I guess it's probably for monster projectiles.
RE: Projectiles don't inherit pitch?
So I went ahead and checked it pretty quickly (so I could be wrong, and testing is required) and here's what I found:
Don't use sin(momz)/cos(momx) to determine pitch. It's absolutely wrong. I should have checked it myself before passing on the info from another source.
While it isn't actually linear, the function of pitch where Pitch = arcsin(momz/projectile_speed) behaves pretty close to a linear function for any given speed. So close in fact that you could actually probably spawn other projectiles from monster projectiles that have their pitch set through the method I'm about to list and nobody would be able to tell the difference.
The function to determine what number to use to approximate the pitch is as follows: Q = (arcsin((x/2)/x)/(x/2)), or Q = 60/x, where x is the projectile speed.
That gets it really close, and it can be used easily with either A_SetPitch or A_CustomMissile as Dark Assassin listed.
For reference here is the result for projectile speeds 1-20:
Don't use sin(momz)/cos(momx) to determine pitch. It's absolutely wrong. I should have checked it myself before passing on the info from another source.
While it isn't actually linear, the function of pitch where Pitch = arcsin(momz/projectile_speed) behaves pretty close to a linear function for any given speed. So close in fact that you could actually probably spawn other projectiles from monster projectiles that have their pitch set through the method I'm about to list and nobody would be able to tell the difference.
The function to determine what number to use to approximate the pitch is as follows: Q = (arcsin((x/2)/x)/(x/2)), or Q = 60/x, where x is the projectile speed.
That gets it really close, and it can be used easily with either A_SetPitch or A_CustomMissile as Dark Assassin listed.
For reference here is the result for projectile speeds 1-20:
Code: Select all
1 60
2 30
3 20
4 15
5 12
6 10
7 (60/70)
8 7.5
9 (20/3)
10 6
11 (60/11)
12 5
13 (60/13)
14 (30/7)
15 4
16 3.75
17 (60/17)
18 (10/3)
19 (60/19)
20 3RE: Projectiles don't inherit pitch?
Ha. We need more nerds like Scroton to do our trig calculations for us. :p
Thanks! I never actually considered that speed affects it.
Thanks! I never actually considered that speed affects it.
Reinforcements: midgame Survival joining/respawning
Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)

Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)

- Dark-Assassin
- Maintenence Crew
- Posts: 968
- Joined: Fri May 25, 2012 4:25 am
RE: Projectiles don't inherit pitch?
Neither did I.
Though, I did make it for a projectile with 10 speed.
This table would be handy. *saving*
Though, I did make it for a projectile with 10 speed.
This table would be handy. *saving*
[/spoiler]
