How can you change a units "PITCH" After The Units Created?

Arkless

New Member
Reaction score
31
I Belive this might BE IT! The bottom one.

Starcraft 2 Has its Z/(x/y) Backwards from what we thought.

Can you check If this is right?! I think it is! :)

*scratches his head* this would make no real difference (first thought), it would just change the angle. Everything missing to do roll + pitch + yaw is the up-vektor wich I couldn't get to respond to any value I tested. No matter wich value I used, it always tried to be as close to 0/0/1 as possible with the given forward(mathematically out)-vector.
 

rover2341

Is riding a roller coaster...Wee!
Reaction score
113
Not sure then, Maybe it shouldnt work but it is for me.
I wanted to be sure so I messed around with it for about in hour.

Can you test the map and tell me if it works for you?

I use moonlight but this is my full code
Code:
////////////////////////////////////////////////////
// Title: Changing a units yaw and pitch demo     //
// Version: 1.0                                   //
//                                                //
//                                                //
// Notes: If a unit, turns upside down at any     //
//        point it will roll 180 Degrees. Ground  //
//        units dont seem to work right even if   //
//        you make them float.                    //
//                                                //
////////////////////////////////////////////////////
// Trigger Variables                              //
////////////////////////////////////////////////////
trigger AfterInit;
trigger Spin;

////////////////////////////////////////////////////
// Varibles                                       //
////////////////////////////////////////////////////
unit aUnit = null;
fixed pitchG = 0;
fixed yawG = 0;

////////////////////////////////////////////////////
// First Fuction To Run                           //
////////////////////////////////////////////////////
static
{     
    AtInit();   
}

////////////////////////////////////////////////////
// At Init                                        //
////////////////////////////////////////////////////
void AtInit()
{ 
    
    libNtve_gf_CreateUnitsAtPoint2(1, "VoidRay", 0, 1, RegionGetCenter(RegionPlayableMap()));
    UnitSetHeight(UnitLastCreated(), 3, 0.0);
    aUnit = UnitLastCreated();            

    AfterInit_Init();
    Spin_Init();
}

////////////////////////////////////////////////////
// After Init                                     //
////////////////////////////////////////////////////
bool AfterInit_Func (bool testConds, bool runActions) 
{
    // Actions
    if (!runActions) 
    {
        return true;
    }
    
    ChangePitch(aUnit, 0);
    return true;
}

void AfterInit_Init()
{
    AfterInit = TriggerCreate("AfterInit_Func");
    TriggerAddEventTimeElapsed(AfterInit, 1.0, c_timeGame);
}

////////////////////////////////////////////////////
// Spin (Periodic Timer)                          //
////////////////////////////////////////////////////
bool Spin_Func (bool testConds, bool runActions)
{
    pitchG = pitchG + 1;
    yawG = yawG + 1;
    
    ChangeOrientation(aUnit, yawG, pitchG);
//    ChangePitch(aUnit, pitchG);
    return true;
}

void Spin_Init ()
{
    Spin = TriggerCreate("Spin_Func");
    TriggerAddEventTimePeriodic(Spin, .001, c_timeGame);
}

////////////////////////////////////////////////////
// ChangePitch                                    //
////////////////////////////////////////////////////
void ChangePitch(unit target, fixed pitch)
{
    
    TriggerDebugOutput(1, StringToText("Pitch: " + pitch), true);
    TriggerDebugOutput(1, StringToText(" "), true);    
    
    // Variable Declarations
    fixed yaw;
    fixed forwardX;
    fixed forwardY;
    fixed forwardZ;
    fixed upX;
    fixed upY;
    fixed upZ;

    // Variable Initialization
    yaw = UnitGetFacing(target);  
    forwardX = Cos(yaw) * Sin(pitch);
    forwardY = Sin(yaw) * Sin(pitch);
    forwardZ = Cos(pitch);
    upX = 0;
    upY = 0;
    upZ = 0;
    
    // Implementation
    libNtve_gf_SendActorMessageToUnit(target, libNtve_gf_SetRotation(forwardX, forwardY, forwardZ, upX, upY, upZ));
    
}

////////////////////////////////////////////////////
// ChangeOrientation                              //
////////////////////////////////////////////////////
void ChangeOrientation (unit target, fixed yaw, fixed pitch) 
{    
    TriggerDebugOutput(1, StringToText(" "), true);    
    TriggerDebugOutput(1, StringToText(" "), true);    
    TriggerDebugOutput(1, StringToText(" "), true);    
    TriggerDebugOutput(1, StringToText(" "), true);    
    TriggerDebugOutput(1, StringToText(" "), true);    
    TriggerDebugOutput(1, StringToText(" "), true);    
    TriggerDebugOutput(1, StringToText(" "), true);    
    TriggerDebugOutput(1, StringToText(" "), true);    
    TriggerDebugOutput(1, StringToText(" "), true);    
    TriggerDebugOutput(1, StringToText(" "), true);    
    TriggerDebugOutput(1, StringToText(" "), true);    
    TriggerDebugOutput(1, StringToText(" "), true);     
    TriggerDebugOutput(1, StringToText(" "), true);    
    TriggerDebugOutput(1, StringToText(" "), true);    
    TriggerDebugOutput(1, StringToText(" "), true);    
    TriggerDebugOutput(1, StringToText(" "), true);    
    TriggerDebugOutput(1, StringToText(" "), true);    
    TriggerDebugOutput(1, StringToText(" "), true);    
    TriggerDebugOutput(1, StringToText(" "), true);    
    TriggerDebugOutput(1, StringToText(" "), true);    
    TriggerDebugOutput(1, StringToText(" "), true);    
    TriggerDebugOutput(1, StringToText(" "), true);    
    TriggerDebugOutput(1, StringToText(" "), true);    
    TriggerDebugOutput(1, StringToText(" "), true);    
    TriggerDebugOutput(1, StringToText(" "), true);    
    TriggerDebugOutput(1, StringToText(" "), true);    
    TriggerDebugOutput(1, StringToText(" "), true);     
    TriggerDebugOutput(1, StringToText(" "), true);    
    TriggerDebugOutput(1, StringToText(" "), true);    
    TriggerDebugOutput(1, StringToText(" "), true);    
    TriggerDebugOutput(1, StringToText(" "), true);    
    TriggerDebugOutput(1, StringToText(" "), true);      
    TriggerDebugOutput(1, StringToText("Pitch: " + pitch + "   Yaw: " + yaw), true);
    
    // Variable Declarations
    fixed forwardX;
    fixed forwardY;
    fixed forwardZ;
    fixed upX;
    fixed upY;
    fixed upZ;

    // Variable Initialization    
    forwardX = Cos(yaw) * Sin(pitch);
    forwardY = Sin(yaw) * Sin(pitch);
    forwardZ = Cos(pitch);
    upX = 0;
    upY = 0;
    upZ = 0;
    
    // Implementation
    libNtve_gf_SendActorMessageToUnit(target, libNtve_gf_SetRotation(forwardX, forwardY, forwardZ, upX, upY, upZ));
}
 

Attachments

  • Create Unit And Change Pitch.zip
    7.1 KB · Views: 200

eXirrah

New Member
Reaction score
51
In the 3D Rotation article I read that the Forward and Up vectors must
be perpendicular.

So if you want to rotate the unit the vectors must rotate like I draw on
the image. The problem is with the math, I will try to create a function
that calculates it right later.

Model%20Rotation.jpg
 

Arkless

New Member
Reaction score
31
Not sure then, Maybe it shouldnt work but it is for me.
I wanted to be sure so I messed around with it for about in hour.

Can you test the map and tell me if it works for you?

I use moonlight but this is my full code
Maybe my understanding of english is just off. I thought the yaw rotation was influenced by the pitch rotation (translating words misleads sometimes :p).
Well, if this is what you wanted then it's fine ^^.


In the 3D Rotation article I read that the Forward and Up vectors must
be perpendicular.

So if you want to rotate the unit the vectors must rotate like I draw on
the image. The problem is with the math, I will try to create a function
that calculates it right later.

I already did that, you might or might not have noticed...
For pitch and yaw that would be (I thought about it yesterday, but this should be it):

out_X = Cos(yaw) * Cos(pitch)
out_y = Sin(yaw) * Cos(pitch)
out_z = sin(pitch)
up_x = Cos(yaw) * (-Sin(pitch))
up_y = Sin(yaw) * (-Sin(pitch))
up_z = Cos(pitch)


For starters just try easy stuff, like (ox=1) and (uz=-1). This "should" make the unit be upside down.
 

rover2341

Is riding a roller coaster...Wee!
Reaction score
113
Currently Working
X = Cos(rotation) * Sin(pitch)
y = Sin(rotation) * Sin(pitch)
z = Cos(pitch)

This lets me set the pitch and the yaw.
The issue is when a unit is about to go upside down it auto rolls 180 degrees.

Not Currently Working
1. The unit auto rolls when its going to be upside down. Thats a issue a major issue for my game. The cart would flip to the cart would either flip to the other side of the track go when it rolls, would be have the wrong side of the cart on the track.
2. Being able to set roll would be great. (doesn't have to work, for my means)

Is the math right, with what I have working?
No Idea if its even close, I just reversed your z/(xy) graph to a (xy)/z graph and it seemed to make it work.

I Made a new map that does this. Does what I say currently working work?

http://www.thehelper.net/forums/showthread.php?p=1287337#post1287337
 

Arkless

New Member
Reaction score
31
With this, I am getting the yaw and pitch to work even if it shouldn't be working, the roll flips 180 if the unit trys to go upside down though.
Yes, I misunderstood the meaning of "yaw", yaw works perfectly well. The problem with flipping by 180 degrees is because we cant use the up vector. It's always as close to 0/0/1 as possible, thus the top side of the model can never face the ground.

I gota run but Ill be back and see if i can understand whats up.
So with that map your not getting full rotation and full yaw. Right?
If you are then continuing is to fix the roll or, Is that map not working?
I am getting a full rotation (pitch and yaw), the problem is that we can't tell him to go upside down without the up vector.

I won't be testing around anymore, because as long as I cant use the up-vector, there isn't anymore I could do.
 

rover2341

Is riding a roller coaster...Wee!
Reaction score
113
Now I get it, K If I get any thing working with the up-vector ill let you know.

Thanks Man :)
 

eXirrah

New Member
Reaction score
51
The functions Set Rotation and Set Bearings are bugged.

Set Rotation - Cannot rotate the actor around the X axis (roll). weir
stuff happens when you rotate the actor by Z(yaw) or Y(pitch) and set
X (roll) <> 0, 180. It is as if the roll angle is not set to rotaiton around
the X Axis but split and added to the rotations around Z and Y axes.

With no proper rotation around X axis(roll) the model flip when it rotates
to 90, 270 degrees around Y axis (pitch) cannot be avoided.

I've uploaded a map with a function that calculates the Forward and Up
coordinates of the rotation vectors function properly from yaw, roll and
pitch angles, but I couldn't fix the bugs I explained above.

So basicly this is a pitch+yaw function, but if Blizzard fix the X rotation
(roll) then this function should be able to do pitch+yaw+roll.

Download poke.SC2Map.
 

Arkless

New Member
Reaction score
31
The functions Set Rotation and Set Bearings are bugged.

Set Rotation - Cannot rotate the actor around the X axis (roll). weir
stuff happens when you rotate the actor by Z(yaw) or Y(pitch) and set
X (roll) <> 0, 180. It is as if the roll angle is not set to rotaiton around
the X Axis but split and added to the rotations around Z and Y axes.

With no proper rotation around X axis(roll) the model flip when it rotates
to 90, 270 degrees around Y axis (pitch) cannot be avoided.

I've uploaded a map with a function that calculates the Forward and Up
coordinates of the rotation vectors function properly from yaw, roll and
pitch angles, but I couldn't fix the bugs I explained above.

So basicly this is a pitch+yaw function, but if Blizzard fix the X rotation
(roll) then this function should be able to do pitch+yaw+roll.

Download poke.SC2Map.

We got pitch and yaw to work fine already.
I still took a look at your map, when I saw the math stuff I thought it looks kinda... wrong. I tested it. I took another short look at your code.

Now I'm pretty sure you did something wrong, you are increasing the pitch value and call your function with. Said function changes pitch and yaw with only the pitch parameter changing. The pitch angle never goes past a certain point (up/down), even thought you are increasing it past 360 (wich should make it a full circle).
 

eXirrah

New Member
Reaction score
51
Sadly, you are right. This is a pitch+yaw function

I didn't do anything wrong man. I did what I draw on the image a few
posts back. The rotation matrix of rotation around an arbitrary axis is huge. I used
it to calculate the pitch because after changing the yaw and roll of the
model, changing its pitch is no longer rotating the vectors around the
world's Y axis, but around a local one for the model (I draw the local for
the model axes on the image in purple in step 4). I represent the new
axis by R vector and calculate the rotation matrix elements. The I
multiply the Forward and Up vectors by the matrix.

The rot_R coordinates contain the matrix elements. For example
rot_Rx.x=a11, rot_Ry.z = a23 ...
Try adding a roll angle to your function and the results will be the same.

The problem is that the Up vector coordinates cannot be changed.
It looks like the Up vector is hard coded to (0,0,1) and there is nothing
we can do to change that.

Unless Blizzard fix that my function works just as yours, I tested it
and it really does ... so I doubt that my calculations are wrong.

If you pass a roll angle value different than 0,180,360 ... then weird
stuff happens. The roll angle depends on the position of the Up vector,
that's why it doesn't work, so set the t_roll variable to 0 and the
function does change yaw+pitch properly.
 

Arkless

New Member
Reaction score
31
Sadly, you are right. This is a pitch+yaw function

I didn't do anything wrong man. I did what I draw on the image a few
posts back. The rotation matrix of rotation around an arbitrary axis is huge. I used
it to calculate the pitch because after changing the yaw and roll of the
model, changing its pitch is no longer rotating the vectors around the
world's Y axis, but around a local one for the model (I draw the local for
the model axes on the image in purple in step 4). I represent the new
axis by R vector and calculate the rotation matrix elements. The I
multiply the Forward and Up vectors by the matrix.

The rot_R coordinates contain the matrix elements. For example
rot_Rx.x=a11, rot_Ry.z = a23 ...
Try adding a roll angle to your function and the results will be the same.

The problem is that the Up vector coordinates cannot be changed.
It looks like the Up vector is hard coded to (0,0,1) and there is nothing
we can do to change that.

Unless Blizzard fix that my function works just as yours, I tested it
and it really does ... so I doubt that my calculations are wrong.

If you pass a roll angle value different than 0,180,360 ... then weird
stuff happens. The roll angle depends on the position of the Up vector,
that's why it doesn't work, so set the t_roll variable to 0 and the
function does change yaw+pitch properly.

I'm not gonna argue with you about your calculation being right or wrong, I didn't take my time to read through everything. I just thought you did too much for a single 3D rotation (and seeing that you increased the pitch parameter without it doing a whole circle told me something is wrong as well).
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • 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
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top