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

Arkless

New Member
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!
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

eXirrah

New Member
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.

 

Arkless

New Member
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!
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
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!
Now I get it, K If I get any thing working with the up-vector ill let you know.

Thanks Man :)
 

eXirrah

New Member
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
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
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
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.
  • The Helper The Helper:
    basically it is linux
  • The Helper The Helper:
    OMG it is BanLord as Blackveiled on the forum
  • The Helper The Helper:
    what is up buddy
  • jonas jonas:
    thanks for the tip, that sounds cool. Never heard about the VCS before but seems like it should be a good match
  • tom_mai78101 tom_mai78101:
    The winter vacation left a toll on me. I missed staying up late and sleeping in late.
  • C Cherry.Grove:
    i haven't looked into it yet
  • C Cherry.Grove:
    If I could use something Python compatible it would save me some learning
  • C Cherry.Grove:
    But Unity might be easiest
  • C Cherry.Grove:
    looking at old posts here makes me happy. Makes me be all like "wow I was pretty smart in 2009"
  • C Cherry.Grove:
    mostly failing at life through adulthood really demotivated me for a while
  • C Cherry.Grove:
    ....what I don't get is why the fuck they would force us to permanently convert to a version of the game everyone fucking hated : \
  • C Cherry.Grove:
    Raid Shadow Legends texture pack smh
  • jonas jonas:
    Most people fail at life throughout their adulthood. Sometimes we get to learn from it. Usually it just feels like crap.
    +1
  • The Helper The Helper:
    What does not kill you makes you stronger is what they say
  • C Cherry.Grove:
    for real! :cool:
  • Varine Varine:
    Are we still on the topic of failing? I failed lots!
  • jonas jonas:
    If you ever want to talk about it we're here. The way I see it, you're still around. That required a few very difficult successes if you ask me:)
  • Varine Varine:
    I posted a thing here a while ago about my failures if it makes you feel better to hear about other people failing. Drugs and whatnot, I had a lot more fun than was healthy. I'm still a failure, but very few of us actually get to be the self made billionaire. Luck is the only thing that will take you as far as already having money a lot of the time, and the easiest way to get catch that is with a very wide net and the willingness to let other things loose.
  • Varine Varine:
    Have fun, do your best, something about Edison's light bulb not working until he stole it.
  • jonas jonas:
    Eh. Don't define success as being a billionaire or even millionaire. Success is about overcoming your personal challenges. And if you can get to a place in life where you can love yourself, that is winning it big time
  • jonas jonas:
    Being a billionaire probably sucks, you can't go out in public like a random person anymore and you always need a bunch of big guys following you around discreetly
  • jonas jonas:
    And you'll never know if anyone you know really likes you or is just seeing you as a big money sack
  • jonas jonas:
    Most of the best fun I've ever head was with a group of friends eating pizza or drinking a good 10$ bottle of wine, when I had maybe 100$ on my account. Or the time when I was so broke, my friends visited me with bags of ingredients and I cooked for us, because I didn't have money to buy ingredients anymore
  • jonas jonas:
    Or walking with my then-fiancee through the night until dawn, just talking

    Members online

    Affiliates

    Hive Workshop NUON Dome
    Top