How to set Yaw and Pitch

rover2341

Is riding a roller coaster...Wee!
Reaction score
113
About
I am trying to figure out how to use SetUnitLookAt to set my Yaw and pitch.
I changed my model like the quote said, and I can make my model angle at another unit. But I cant figure out how to set the Yaw and Pitch to what i want, with only 1 unit.

You use dummy which has its main bone named "head" and then rotate it with SetUnitLookAt

What I Did
I changed the name of bone_head and it worked.

What Works
Now With 2 units I can have one look at the other at the with yaw and pitch.

What I still Need
I want 1 Unit to be set at yaw and pitch. (x = pitch) (y = yaw)
I understand how to work with "SetUnitLookAt"

Code
Code is done in vJass.

JASS:
library SetupGame initializer InitA

    function environment takes nothing returns nothing
        call SetSkyModel( "Environment\\Sky\\LordaeronSummerSky\\LordaeronSummerSky.mdl" )
        call FogEnableOff(  )
        call FogMaskEnableOff(  )
        call UseTimeOfDayBJ( false )
        call SetTimeOfDay( 12 )
    endfunction

    
    function createUnitWithYawAndPitch takes nothing returns nothing
    
        local integer myUnitType = 'Trac'
        local unit myUnit
        local unit myUnit2
        
        set myUnit = CreateUnit(Player(0),myUnitType,200,200,90) 
        set myUnit2 = CreateUnit(Player(0),myUnitType,0,0,90) 
        call SetUnitFlyHeight(myUnit,400,0)
        call SetUnitLookAt(myUnit,"head", myUnit2, 0,0,0)

    endfunction  

//===========================================================================
    function InitA takes nothing returns nothing
        
        call createUnitWithYawAndPitch()
        call environment()
        
    endfunction
     
endlibrary
 

Attachments

  • SetYawAndPitch v2.w3x
    19.2 KB · Views: 294

rover2341

Is riding a roller coaster...Wee!
Reaction score
113
Bump.

If anyone could give me any information on if this is possible or not, or how to do it would be great. Thanks :)
 

rover2341

Is riding a roller coaster...Wee!
Reaction score
113
I updated the first post, with new info, I am a few steps farther then i was before. I just need help figuring out how to work it now.
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
Tell the unit to look at itself, and use the 3 offsets to get yaw and pitch. I am assuming that theta is measured via the standard method of counterclockwise from 0, and phi is measured as the angle up from the horizon. Because that's how I do math.

Anyhow:

Yaw:
x = Cos(pitch)*Cos(yaw)
y = Cos(pitch)*Sin(yaw)

Pitch:
z = Sin(pitch)


So basically:
[ljass]call SetUnitLookAt(myUnit,"head", myUnit,Cos(pitch)*Cos(yaw),Cos(pitch)*Sin(yaw),Sin(pitch))[/ljass]

Note that I didn't actually test this, but its math seems to check out. It should work as long as wc3 doesn't take issue with small distances, at which point you could probably fix it by multiplying each of those 3 new values by 1000 or something.

This is accomplished mathmatically by assuming a unit vector points, in spherical coordinates, as <1,yaw,pitch>, and solving for the side lengths.
 

rover2341

Is riding a roller coaster...Wee!
Reaction score
113
Ill Give it a shot. Ill update this post, after I try it out. Thanks


Edit*
It Works, I had issues at first because I was sending in degrees when it wanted radians but I fixed that. Thanks alot.

Here is updated code
JASS:
library SetupGame initializer InitA

    function environment takes nothing returns nothing
        call SetSkyModel( &quot;Environment\\Sky\\LordaeronSummerSky\\LordaeronSummerSky.mdl&quot; )
        call FogEnableOff(  )
        call FogMaskEnableOff(  )
        call UseTimeOfDayBJ( false )
        call SetTimeOfDay( 12 )
    endfunction

    
    function createUnitWithYawAndPitch takes nothing returns nothing
    
        local integer myUnitType = &#039;Trac&#039;
        local unit myUnit

        local real yaw = 90
        local real pitch = 90
        
        set myUnit = CreateUnit(Player(0),myUnitType,0,0,0) 

        call SetUnitFlyHeight(myUnit,400,0)
        call SetUnitLookAt(myUnit,&quot;head&quot;, myUnit,CosBJ(pitch)*CosBJ(yaw),CosBJ(pitch)*SinBJ(yaw),SinBJ(pitch))

    endfunction  

//===========================================================================
    function InitA takes nothing returns nothing
        
        call createUnitWithYawAndPitch()
        call environment()
        
    endfunction
     
endlibrary
 

saw792

Is known to say things. That is all.
Reaction score
280
>[ljass]not false[/ljass]

Ahem... [ljass]true[/ljass]
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
[LJASS]not not true[/LJASS]

I wonder if that compiles...
 

rover2341

Is riding a roller coaster...Wee!
Reaction score
113
apparently this doesn't work if the unit is at 0,0. I tried different spots and it wont show up.
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
I remember something about multiplying the values given to SetUnitLookAt by a million to offset some z-level error or something. It was on wc3c, if it comes back up I'll link the post.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top