Aller au contenu

Photo

placeable orientation being ignored


14 réponses à ce sujet

#1
Rolenka

Rolenka
  • Members
  • 2 257 messages
Vector is fine, but it's facing the wrong way. Orientation is defaulting to 0,0,0. I was giving it -40, but figured maybe it didn't accept a negative number, so I changed it to 320. Still no dice.

Any idea why? 

const string SF_X1_FORMS_TOME = "sf_x1_grantforms";
const resource SF_X1_FORMS_TOME_RESOURCE = R"sf_x1_grantforms.utp";

void main()
{
    object oMainControlled = GetMainControlled();
    object oTome = UT_GetNearestObjectByTag(oMainControlled, SF_X1_FORMS_TOME);

    if (!IsObjectValid(oTome))
    {
        location lSpawn = Location(GetArea(oMainControlled), Vector(134.601,56.4369,32.2178), 320.0);
        CreateObject(OBJECT_TYPE_PLACEABLE, SF_X1_FORMS_TOME_RESOURCE, lSpawn);
    }
}


Modifié par Rolenka, 03 juin 2010 - 03:31 .


#2
_L_o_B_o_

_L_o_B_o_
  • Members
  • 117 messages
I had some kind of similar problem setting the orientation of a creature that I had spawned. I had to use SetOrientation() after CreateObject().

Modifié par _L_o_B_o_, 03 juin 2010 - 08:18 .


#3
tmp7704

tmp7704
  • Members
  • 11 156 messages

Rolenka wrote...

Any idea why? 

Orientation seems to need to be 'converted' through rather counter-intuitive system in order to obtain proper value in world coordinates. From wiki ( http://social.biowar...cript_Templates )

Rotation needs to be recalculated before entering it into the script. For positive angles do (180-angle). For negative angles do (-180-(-angle)).



#4
Rolenka

Rolenka
  • Members
  • 2 257 messages
The -180 to +180 range is important to know, thanks. But if that were the problem it would have worked when I was experimenting with -40.

(I've reconsidered, I now like -30 more :happy:)

I'd like to try _L_o_B_o_'s idea, (I found this thread confirming the problem) but I can't quite figure it out. I thought I'd set a vector variable like so. I put this at the line above "location lSpawn":

vector vOrientation = Vector(134.601,56.4369,32.2178), -30.0);


But that returned an "error parsing variable list" on that line.I thought using a variable made sense since I was using the same vector twice.

But I dropped that and did it the lazy way, instead putting this after the CreateObject line: 

//need to get it again in case it wasn't valid before
oTome = UT_GetNearestObjectByTag(oMainControlled, SF_X1_FORMS_TOME);
SetOrientation(oTome, Vector(134.601,56.4369,32.2178), -30.0);


And that said I wasn't using the right parameters for SetOrientation.

If I change it to:

//need to get it again in case it wasn't valid before
oTarget = UT_GetNearestObjectByTag(oMainControlled, SF_X1_FORMS_TOME);
SetOrientation(oTarget, Vector(134.601,56.4369,32.2178), -30.0);


I get an error parsing variable list on the SetOrientation line.

Modifié par Rolenka, 03 juin 2010 - 07:09 .


#5
DavidSims

DavidSims
  • BioWare Employees
  • 196 messages
I'm not certain, but I'm guessing CreateObject just ignores the orientation part of the location for placeables. I would try a SetFacing call after the object is created.



object oPLC = CreateObject(OBJECT_TYPE_PLACEABLE, SF_X1_FORMS_TOME_RESOURCE, lSpawn);

SetFacing(oPLC, 320.0);



You may have to place around with the fFacing paramater. I know there are some issues with what the value means and it doesn't always match the toolset or common sense, but you should be able to get it facing somewhere, and adjust from there.



I don't know if this is an option for you, but it might be easier to pre-place the placeable in the area, and set it to innactive. Then you can grab it by tag or by team and set it active when you want it to appear. So long as the location and orientation are fixed in advance, this is the simpler aproach.

#6
Phaenan

Phaenan
  • Members
  • 315 messages
That'd be because the vector structure doesn't  include the orientation angle. For instance your :
vector vOrientation = Vector(134.601,56.4369,32.2178), -30.0);
Should be like :
vector vOrientation = Vector(134.601, 56.4369, 32.2178);
With the angle actually defined when / if you're making a location with this vector :
location lOrientation = Location(oYourArea, vOrientation, -30.0f)

#7
Phaenan

Phaenan
  • Members
  • 315 messages

DavidSims wrote...
I'm not certain, but I'm guessing CreateObject just ignores the orientation part of the location for placeables. I would try a SetFacing call after the object is created.

I'm not sure CreateObject just ignore the angle, I actually  have a bit of code using the same thingy and it apparently works :
    object oControlledChar = GetMainControlled();
    vector vChar = GetPosition(oControlledChar);
    vChar.x += 5.0f*iDistanceFactor; // ignore those two
    vChar.y += 5.0f*iDistanceFactor;
    location lScarecrow = GetSafeLocation(Location(GetArea(oControlledChar), vChar, GetFacing(oControlledChar, FALSE)));
    CreateObject(OBJECT_TYPE_PLACEABLE, R"phae_forge_spchange_dummy.utp",  lScarecrow);

To be sure I just tried two spawns with that code, making the char turn and move a tad between the two runs :

Posted Image


So in the end, it may be as tmp7704 said, something related to that "320.0f" param initially used. :o

Modifié par Phaenan, 03 juin 2010 - 07:40 .


#8
Rolenka

Rolenka
  • Members
  • 2 257 messages

Phaenan wrote...

That'd be because the vector structure doesn't  include the orientation angle. For instance your :
vector vOrientation = Vector(134.601,56.4369,32.2178), -30.0);
Should be like :
vector vOrientation = Vector(134.601, 56.4369, 32.2178);
With the angle actually defined when / if you're making a location with this vector :
location lOrientation = Location(oYourArea, vOrientation, -30.0f)


But SetOrientation only takes an object and a vector, not a location. And vectors can't hold angles. So I guess it can't be used to change facing.

Phaenan wrote...
I'm not sure CreateObject just ignore the angle, I actually  have a bit of code using the same thingy and it apparently works :


You know, I had CreateObject make use of the angle a long time ago. It just isn't on this project for some reason.

DavidSims wrote...
object oPLC = CreateObject(OBJECT_TYPE_PLACEABLE, SF_X1_FORMS_TOME_RESOURCE, lSpawn);
SetFacing(oPLC, 320.0);

You
may have to place around with the fFacing paramater. I know there are
some issues with what the value means and it doesn't always match the
toolset or common sense, but you should be able to get it facing
somewhere, and adjust from there.

I don't know if this is an
option for you, but it might be easier to pre-place the placeable in
the area, and set it to innactive. Then you can grab it by tag or by
team and set it active when you want it to appear. So long as the
location and orientation are fixed in advance, this is the simpler
aproach.

Unfortunately I'm working on a PRCSCR to mod Origins, so that won't be an option. But thanks. [smilie]../../../images/forum/emoticons/happy.png[/smilie]

I'm going to fiddle with SetFacing. I'm sure that'll work for me.

#9
Phaenan

Phaenan
  • Members
  • 315 messages

Rolenka wrote...
But SetOrientation only takes an object and a vector, not a location. And vectors can't hold angles. So I guess it can't be used to change facing.


Well, vectors have the habit of having a direction so one can change the facing by setting a vector as the new orientation. It's just that it'll be relative to the (0,0,0) origin and not necessarily be intuitive. Not intuitive at all, actually. ^_~

Modifié par Phaenan, 03 juin 2010 - 08:07 .


#10
Rolenka

Rolenka
  • Members
  • 2 257 messages

Phaenan wrote...

Rolenka wrote...
But SetOrientation only takes an object and a vector, not a location. And vectors can't hold angles. So I guess it can't be used to change facing.


Well, vectors have the habit of having a direction so one can change the facing by setting a vector as the new orientation. It's just that it'll be relative to the (0,0,0) origin and not necessarily be intuitive. Not intuitive at all, actually. ^_~


How can a vector variable have facing if the function to set a vector variable doesn't accept facing? :blink:

#11
CID-78

CID-78
  • Members
  • 1 124 messages
a vector is a line between two points, so obviously it got a facing from origin to whatever coordinate you gave it. otherwise it would have been a point and not a vector.



it's math it might not seem intuative or logical to everyone but it is.



pick up a math book covering linear algebra and if you grasp it, you will grasp vectors and how you can use them in games like DA.

#12
Phaenan

Phaenan
  • Members
  • 315 messages
Well, that's what a vector is; a thingy defining a length and a direction. I don't have a head for maths so my explaination prolly won't be any good, but basically when you're defining a vector in your code you're setting the position of a point in relation to an arbitrary reference origin. When using the SetOrientation() function you're just making the object face the same direction as the Origin->Position segment.
Hmm...
I warned I would be bad at explaining it !


// Edit :
Pfew, CID-78 hopefully beat me to it. :P

Modifié par Phaenan, 03 juin 2010 - 08:30 .


#13
tmp7704

tmp7704
  • Members
  • 11 156 messages

DavidSims wrote...

I'm not certain, but I'm guessing CreateObject just ignores the orientation part of the location for placeables. I would try a SetFacing call after the object is created.

It definitely does take it into account, as tweaking that parameter did have effect on the placeable i was adding to the Warden Cache area. The info from the page i linked seems to be accurate, or at least it did allow me to get the intended orientation, while my initial attempt of just copying the value from area editor had the placeable also rotated somewhat, but not the way i wanted.

#14
Rolenka

Rolenka
  • Members
  • 2 257 messages

CID-78 wrote...

a vector is a line between two points, so obviously it got a facing from origin to whatever coordinate you gave it. otherwise it would have been a point and not a vector.

it's math it might not seem intuative or logical to everyone but it is.

pick up a math book covering linear algebra and if you grasp it, you will grasp vectors and how you can use them in games like DA.


By the Maker, I must have had a hole in my head to forget what a vector is. I think I somehow had it confused with a vertex, which doesn't make sense either, but at least it's a single point.

My orientation was not being ignored. It was just wrong because I assumed it would rotate starting from the north, or at least a right angle.

Once you reminded me what "vector" means I sort of drew an imaginary line between the player entry point and the item spawn point and approximated my rotation from that. (as I said, it's a PRCSCR) I had to take screenshots to track the progression and get it just right.

The vector worked as I expected it to in my earlier project because the player entry point and my placeable were straight along a north/south line.

Thank you for all of your help, everyone!

Modifié par Rolenka, 04 juin 2010 - 01:00 .


#15
Craig Graff

Craig Graff
  • Members
  • 608 messages
In the future you will likely save yourself a lot of trouble visualizing if you just use AngleToVector in combination with SetOrientation.