Aller au contenu

Photo

Problem with script - script to make player face waypoint


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

#1
el.sombrero

el.sombrero
  • Members
  • 100 messages
 Hey dudes,

 I want to create triggers that force specific camera angles at specific momentsof my module (I want to force the camera to be behind the player at certain moments). I came out with this script, using lillacs soul, but it isnt working. I even put a floattextstring at the end of the script to check if the script is been read. The message is displayed, but the camera doesnt go where I need it to go. I directed the script to a waypoint named "forefront", put where I want the player to look at.
 The script is the following

/*   Script generated byLilac Soul's NWN Script Generator, v. 2.3
For download info, please visit:http://nwvault.ign.com/View.php?view=Other.Detail&id=4683&id=625    */
//Put this script OnEntervoid main(){
object oPC = GetEnteringObject();
if (!GetIsPC(oPC)) return;
object oTarget;oTarget = GetObjectByTag("forefront");
AssignCommand(oPC, SetFacingPoint(GetPosition(oTarget)));
FloatingTextStringOnCreature("its been read", oPC);
}

Any idea?

#2
Morbane

Morbane
  • Members
  • 1 883 messages
Try GetWaypointByTag("forefront")

Also you never mentioned if this was for a cutscene or not - that is pretty much the only time the camera can be controlled.

Also too, you never "Get" the camera. If you simply just want the player to face a certain direction then the first suggestion might help...

Lastly you might even try to use a placeable iPoint rather than a waypoint - then it would be GetObjectBYTag("forefront"); (I think):whistle:

Modifié par Morbane, 16 mai 2012 - 09:33 .


#3
Dann-J

Dann-J
  • Members
  • 3 161 messages
You can also try the 'golden rule' of assigning a creature or PC an action - ALWAYS ClearAllActions() first. Otherwise your scripted actions are likely to succeed only some of the time.

#4
el.sombrero

el.sombrero
  • Members
  • 100 messages
Where and how do I input the "Clear AllActions"? Would it be something like:
OnEntervoid main(){
ClearAllActions()
object oPC = GetEnteringObject();
????

#5
el.sombrero

el.sombrero
  • Members
  • 100 messages
By the way, it isnt a cutscene... cant I force the camera to rotate (so its positioned behind the players avatar) outside a cutscene?

#6
kevL

kevL
  • Members
  • 4 078 messages
el.s,

i posted a script that pretty much works here


don't get overwhelmed by it. Just follow it through line by line & notice the order of things -- from start to finish. It's an onEnter script (for a trigger) and contains a proper usage for ClearAllActions ...

#7
el.sombrero

el.sombrero
  • Members
  • 100 messages
Hey, problem solved. Kevl (thx dude!) helped out with this script.

void main()
{
if (GetLocalInt(OBJECT_SELF, "bDone")) return;

object oPC = GetEnteringObject();
if (!GetIsPC(oPC)) return;

// from 'x0_inc_generic' GetIsFighting()
object oAttack = GetAttemptedAttackTarget();
object oSpellTarget = GetAttemptedSpellTarget();
if (GetIsObjectValid(oAttack) || GetIsObjectValid(oSpellTarget)) return;

AssignCommand(oPC, ClearAllActions());
SetLocalInt(OBJECT_SELF, "bDone", TRUE);

object oTarget = GetObjectByTag("kg001_ct_dov");

// from 'ginc_cutscene' SetCameraFacingPoint()
vector vPC = GetPosition(oPC);
vector vTarget = GetPosition(oTarget);
// this gives us a vector pointing from PC to Target
vector vDifference = vTarget - vPC;
// we just need the angle of that vector
float fDirection = VectorToAngle(vDifference);

AssignCommand(oPC, SetFacingPoint(vTarget));
AssignCommand(oPC, SetCameraFacing(fDirection, 6.f, 85.f,
CAMERA_TRANSITION_TYPE_FAST));

SendMessageToPC(GetFirstPC(FALSE), ". Camera facing theDove, done");
}