Aller au contenu

Photo

Another Facing Script


  • Veuillez vous connecter pour répondre
10 réponses à ce sujet

#1
Morbane

Morbane
  • Members
  • 1 883 messages
Made this ga_ script to make an npc face away from PC_Speaker at a certain time, but the npc just twists a slight bit not really facing away.

What to do?

// ga_face_away
#include "ginc_param_const"
void main(string sFacer, int bLockOrientation = TRUE)
{	
    object oPC = GetPCSpeaker();
    object oFacer = GetTarget(sFacer, TARGET_OWNER);	
    float fFacing = GetFacing(oPC);	
    vector vTarget =  AngleToVector(fFacing);	
    AssignCommand(oFacer, ActionDoCommand(SetFacingPoint(vTarget, bLockOrientation)));    
    AssignCommand(oFacer, ActionWait(0.5f));
}

Modifié par Morbane, 26 septembre 2012 - 07:09 .


#2
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
Two possibilities, first, that ActionWait might be cancelling out the SetFacingPoint action, especially as things get queued up in the action queue. The conversation itself, with all its associated animations, might be messing up the action queue as well.

Second possibility, your fFacing might not be what you want it to be. As is, it seems the NPC will turn and face the same direction that the PC is facing (or rather, the direction the PC was facing when they arrived at the spot where the conversation was initiated--facings don't seem to get consistently updated). What you want, though, is for the NPC to face away from the PC. So I would get the NPC's current facing, assuming that they're facing the PC to begin with, and then add 180 degrees to turn them around. If the NPC's facing is bugged to begin with, you might have to do a little vector math to figure it out long-hand.

A simpler kludge would be to set down an i-point where you want the NPC to be facing, and then set the i-point as the listener when the NPC says his line.

#3
kamal_

kamal_
  • Members
  • 5 260 messages
I haven't used AngleToVector, but I suspect it doesn't do what your code looks like it thinks that function does. It looks like your npc is carrying out the order correctly, but you are making the npc face a point a small distance in front of the pc because of AngleToVector.

#4
Morbane

Morbane
  • Members
  • 1 883 messages
LoTRS, ya I noticed the ActionWait after I posted, so I will mess with that and test. I also thought about the +180 thing too... after posting. Thanks.

kamal_, your thoughts mirror my own as well. I kind of figured that there is a possibility that the code is just wrong.

... Have to test LoTRS's ideas first tho. I'll post back after I have tested.

:wizard:

Modifié par Morbane, 26 septembre 2012 - 08:42 .


#5
kevL

kevL
  • Members
  • 4 075 messages
also try switching out GetFacing( ) w/

location lPC = GetLocation(oPC);
float fFacing = GetFacingFromLocation(lPC);


and then perhaps GetOppositeDirection( ) in 'x0_i0_position' for SetFacing( )


I was getting better results yesterday like that, but still not consistent,

#6
Dann-J

Dann-J
  • Members
  • 3 161 messages
I've found quite a few useful functions in x0_i0_position. There might be something in there that already does what you want.

#7
Morbane

Morbane
  • Members
  • 1 883 messages
Cool - a while back I was looking at x0_i0_position to try and customise that moving placeable issue that came up back then - there is a nss group for that on the Vault somewhere...

Thanks kevL - your code finesse in action again! I'll give it a try tonight.

#8
Morbane

Morbane
  • Members
  • 1 883 messages
 R/L














:alien:

#9
kevL

kevL
  • Members
  • 4 075 messages
and now for something completely different


Image IPB

#10
kamal_

kamal_
  • Members
  • 5 260 messages

kevL wrote...

and now for something completely different


Image IPB

Morbane's current avatar frowns on your shenanigans, and probably everything else. :D

#11
Morbane

Morbane
  • Members
  • 1 883 messages

kamal_ wrote...

Morbane's current avatar frowns on your shenanigans, and probably everything else. :D


What brought you to that insidious conclusion?
:whistle: