How to set Yaw and Pitch for a Unit

Tutorial By rover2341

How to set Yaw and Pitch for a Unit


About
What this tutorial shows you how to do, is how to change a unit with a model
that has had a tweak done to it,be able to change the yaw and pitch with code.

Note: I currently have Yaw and Pitch. Ill add how to do roll also at some point in the future (1 - 3 weeks).

Note: It Currently Flips the model after 90 degrees and 270 degrees. Making it look werid for my roller coaster project.

What are Yaw, pitch, and roll?

(Image)

Yaw
[SPOILER]
(Image)
[/SPOILER]

Pitch
[SPOILER]
(Image)
[/SPOILER]

Roll
[SPOILER]
(Image)
[/SPOILER]


How To set Just Yaw and Pitch
There are 3 steps.

The first step is to setup the model.
The second step is to create a unit, and two variables called "Yaw" and "Pitch".
The third step is to set the yaw and pitch in the code.

Step 1

1. Download Magos' Model Editor here
2. Open the model in Magos
3. Select "Windows -> Node Manager"
4. Right-click the helper (Balloon with an "i" inside) called "Bone_Root" or similar
5. Select "Edit Node"
6. Rename it into "Bone_Head"
7. Save
8. Import into map

Step 2

1.Setup the model type (this is the value that repesents your custom model)
2.Change "Art - Animation - Blend Time (seconds)" to 0 seconds.
3.Create a Unit
4.Create two real variables that have a number that is a degree.

//Trac is just for my custom model yours is likely difffernt
local integer myUnitType = 'Trac'

local unit myUnit = CreateUnit(Player(0),myUnitType,0,0,0)

        local real yaw = 90
        local real pitch = 90
        
        if ( pitch == 90.0 ) then
            set pitch = 89
        endif

        if ( pitch == 270.0 ) then
            set pitch = 269
        endif


Step 3

1. Set Yaw and Pitch for unit.

call SetUnitLookAt(myUnit,"head", myUnit,CosBJ(pitch)*CosBJ(yaw)*1000000.,CosBJ(pitch)*SinBJ(yaw)*1000000.,SinBJ(pitch)*1000000.)


The Attached Map is in vJass

Credits
grim001 - Found a similar tutorial made by him, Added the 1000000 that fixed it.
KaTTaNa - Did the part that said you cant be 90 for pitch.
Michael Peppers - Step 1
uberfoop - Step 3
Viikuna - Step 1
Rover2341 - Step 2 and put them all together in this thread.

Click here to comment on this tutorial.
 
 
Blizzard Entertainment, Inc.
Silkroad Online Forums
Team Griffonrawl Trains Muay Thai and MMA fighters in Ohio.
Apex Steel Pipe - Buys and sells Steel Pipe.