Jump to content

Making Player Look At Something


Recommended Posts

So, after spending two precious days from further developing my own mod, here is the conclusion:
1) The "Game.SetCameraTarget()" can only be used with actors. And as Alaebasta wrote (this is possible it can easily be done).
2) The "ActorRef.SetLookAt()" can only be used with NPCs.
* There are two ways that you can use this fanction on the player "ActorRef.SetLookAt()", but requireds some extra work and a bounch of scripting and testing that i'm not willing to do since i won't be needing it, this is as far as i'll go with this.
If i find myself in need of such a script i'll post it in the future.
This is the two most convenient ways to achieve what you want:
1)
- The POSITIVE with this approach is that is realistic.
- The NEGATIVE is that between the player and the xMarker - target there shouldn't be any other object (obstacle), otherwise the sequence will be interapted.
- You need to align correctly trigger box > xMarker target (where player will move) > Object to look, otherwise you won't get the required result.
* NOTE :
- The script will not continue its functions until the Script finish the auto - pilot, after finishing it will continue executing the rest of the fanctions.
- Only edit the "wait" after the "VisualFX01.Play(xMarkerVisualREF)" to match the FX play time.


Scriptname aXMDplayerAutoPilotToTarget01 extends ObjectReference  
{Disables player's controls and AUTO - PILOT player to a specific target}
 
EffectShader Property VisualFX01  Auto  
{Visual FX to Play on Ref}
 
ObjectReference Property xMarkerVisualREF auto
{xMarker to play the FX}
 
ObjectReference Property CamMoveTargetREF auto
{The xMarker - target where the player will be AUTO-PILOT to}
 
Sound Property SoundFX01  Auto  
{Sound FX 01 to play}
 
int instanceID ;used to store sound ref
 
 
auto state waiting
EVENT onTriggerEnter(objectReference actronaut)
                if actronaut == game.getPlayer()
                    Game.DisablePlayerControls(1, 1, 1, 1, 1, 1, 1)
                    Game.ForceFirstPerson()
                    Utility.wait(0.5)
                    instanceID =  SoundFX01. Play(game.getPlayer())
                    Utility.Wait(0.5)
                    Game.SetPlayerAIDriven(true)
                    game.getPlayer().PathToReference(CamMoveTargetREF, 0.5)
                    Utility.Wait(0.5)
                    VisualFX01.Play(xMarkerVisualREF)
                    Utility.wait(5.0)
                    Game.SetPlayerAIDriven(false)
                    Game.EnablePlayerControls()
                    GoToState("Done")
                    Utility.wait(0.5)
                    self.Disable()
                    Utility.wait(0.5)
                    self.Delete()
            endif
endevent
endstate


 

2)
- The positive here is that the script doesn't care about objects in between (obstacles).
- Second positive is that the Player will face - look exactly where the "xMarker Heading" is looking - targeting.
- NEGATIVE, is unrealistic.

Scriptname aXMDplayerMoveToTarget01 extends ObjectReference  
{Disables player's controls and moves the player to a specific target - xMarker Heading}
 
EffectShader Property VisualFX01  Auto  
{Visual FX to Play on Ref}
 
ObjectReference Property xMarkerVisualREF auto
{xMarker to play the FX}
 
ObjectReference Property PlayerMoveTargetREF auto
{The xMarker Heading- target where the player will be MOVE TO}
 
Sound Property SoundFX01  Auto  
{Sound FX 01 to play}
 
int instanceID ;used to store sound ref
 
 
auto state waiting
EVENT onTriggerEnter(objectReference actronaut)
                if actronaut == game.getPlayer()
                    Game.DisablePlayerControls(1, 1, 1, 1, 1, 1, 1)
                    Game.ForceFirstPerson()
                    Utility.wait(0.5)
                    instanceID =  SoundFX01. Play(game.getPlayer())
                    Utility.Wait(0.5)
                    game.getPlayer().MoveTo(PlayerMoveTargetREF = true)
                    Utility.Wait(0.5)
                    VisualFX01.Play(xMarkerVisualREF)
                    Utility.wait(5.0)
                    Game.EnablePlayerControls()
                    GoToState("Done")
                    Utility.wait(0.5)
                    self.Disable()
                    Utility.wait(0.5)
                    self.Delete()
            endif
endevent
endstate

 

 

 

Both scripts tested and working.

Edited by maxarturo
Link to comment
Share on other sites

Interesting experiment. I made a spider actor, really small and placed it next to where I want the player to look. Player doesn't look at the spider, what does happen is that the Look Up/Down controls get locked and the only way to restore them is to quit game to desktop or main menu.

Link to comment
Share on other sites

If you used the scripts posted above, none of them are for use to look at an actor, but to put the player in a line of sight of the object you want him to look at.

I think the descriptions are more than clear.

Edited by maxarturo
Link to comment
Share on other sites

Is not frustrating, but we all have our days...

Just be clear if you need more help or if there is something that you don't understand.

We were all newbies at one point and some of us got no help from anyone when they started.

 

Just in case you are having trouble.
First script:
aXMDplayerAutoPilotToTarget01
- Make your trigger box and place the script in it (locally).
- Place an "xMarker" outside the trigger box, opposite or left or right of how you will enter the trigger box, so you can see how the script works (test it).
- Be sure that between the trigger box and the xMarker there isn't any other object, should be a clear path.
- In the script's properties Link Ref the "CamMoveTargetREF" to the xMarker.
You are done.
Second script :
aXMDplayerMoveToTarget01
- Make your trigger box and place the script in it (locally).
- Here you will place an "xMarker Heading". And where ever the "xMarker Heading" is looking that's where the player will be looking.
- In the script's properties Link Ref the "PlayerMoveTargetREF" to the "xMarker Heading".
You are done.
The main difference between both scripts is that.
The Realistic approach.
- In the first the player WALKS to the xMarker where he will be force to look at what you want him to look (for 5 sec), in the spot that the sequences stops and the player is facing towards.
The Unrealistic approach.
- In the second script the player gets Teleported (move to) to the xMarker Heading where he will be force to look at what you want him to look (for 5 sec), in the spot that the sequences stops and the player (xMarker Heading) is facing towards.
Edited by maxarturo
Link to comment
Share on other sites

Sorry about that, i made and test the script in the same file, then i posted it.

Change this line :

game.getPlayer().MoveTo(PlayerMoveTargetREF = true)

TO

game.getPlayer().MoveTo(PlayerMoveTargetREF, abMatchRotation = true)

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...