Special effect orientation with offset

Status
Not open for further replies.

Ofel

Level 12
How to make an effect face an angle with offset to its roll and pitch?

For example, an effect's 3D orientation is facing a unit's head, but I want to make it face a little up and a little left of it's current orientation (pitch and roll).

And what is the formula to set an effect facing (the pitch is straight) angle towards a unit? I know I can use roll angle only, but I think I can't make offset facing later.

Last edited:

Antares

Spell Reviewer
Level 25
This is difficult to follow. Could you provide a sketch of the problem?

Ofel

Level 12
This is difficult to follow. Could you provide a sketch of the problem?
Updated.

Antares

Spell Reviewer
Level 25
Jesus, this is complicated. These Yaw, Pitch, Roll angles are defined so awkwardly and have nothing to do with how they're normally defined.

I made a test here and tried to align this Starfall effect to the unit in the way you described. Hope I interpreted it correctly.

It doesn't work 100% yet. The prefactors "Cos(Phi)" and "Sin(Phi)" in the Set Yaw/Pitch functions are wrong. They were just guesses. I'd have to look into the trigonometry formulas for that situation to get the correct ones. I tried rotating the effect to horizontal orientation, then rotating it around the Z-axis so it faces the Paladin + offset, then rotating it back towards the Z-axis to account for the vertical offset, but that didn't work.

Maybe this is still a good starting point or maybe someone smarter can pick it up from here. Also, maybe there is a function someone wrote that converts to these yaw, pitch, roll angles from something more intuitive.

Attachments

• SpecialEffectYawPitchTest.w3m
17.6 KB · Views: 49
Last edited:

Ofel

Level 12
Sorry I might not being too straightforward.
I used this to find the pitch angle of an effect towards a target unit:
JASS:
``````function GetDistance2D takes real x, real y returns real
return SquareRoot(x * x + y * y)
endfunction

function AnglePointsZ takes real distance2D, real z returns real
return Atan2(z, distance2D)
endfunction

// find pitch angle towards target.
// [posX, posY, posZ] is the effect's position.
// [targetX, targetY, targetZ] is the target unit's position.
set anglePointsZ = AnglePointsZ(GetDistance2D(.targetX - .posX, .targetY - .posY), .targetZ - .posZ)``````
Then I use a unit (caster)'s facing angle to be used as the facing angle of the effect (because the caster should always be facing the target unit):
`set cFacing = GetUnitFacing(.node.caster) * bj_DEGTORAD`

At this point, I'm not sure if this is the right way to make the effect face the direction I mentioned above (still the same concept).
JASS:
``````set .pitch = GetRandomReal(anglePointsZ + rPitchLimit[2], anglePointsZ + rPitchLimit[1])
set .roll = GetRandomReal(cFacing - rFacingWidth, cFacing + rFacingWidth)
call BlzSetSpecialEffectOrientation(.rocket, 0, .pitch, .roll)
// I don't use the 'yaw' (0), cuz I don't fully understand how these 3 values work.

// these variables below are initialized earlier.
set rFacingWidth = ROCKETS_FACING_WIDTH / 2. * bj_DEGTORAD
set rPitchLimit[1] = ROCKETS_PITCH_LIMIT_UP * bj_DEGTORAD
set rPitchLimit[2] = ROCKETS_PITCH_LIMIT_DOWN * bj_DEGTORAD``````

Last edited:

Daffa

Level 45
Blizz messes yaw and pitch afair.

Antares

Spell Reviewer
Level 25
You've done a lot of work on this already. Might have been good to include that in the OP .

Ofel

Level 12
Blizz messes yaw and pitch afair.
Yup, this math stuff is blowing my mind.
You've done a lot of work on this already. Might have been good to include that in the OP .
Basically, I only try to understand what some of those lines of formula does from various resources. Then I try to solve them to be the formula I wanted. I never fully understand those trigonometry functions.

What's OP?

Status
Not open for further replies.

Replies
10
Views
1K
Replies
5
Views
782
Replies
6
Views
2K
Replies
4
Views
1K
Replies
7
Views
2K