Jump to content

have already existing door appear in front or back of player ?


silhouett

Recommended Posts

I have never been a math pro :) Using Papyrus I would like some help on how can I make a door I already have appear in front or in back of the player.

 

I can use moveto and get the door to the player and with a slight offset have it away from the player but I dont know how to make it always be in front of the player or rear.

 

I need both options as the door will lead somewhere and then when the player returns he will be where he left from but he should have the door behind him at that point.

 

Any help ?

Link to comment
Share on other sites

Mathless approach: create an empty nif file without any trishapes, but with a node to mark your door's position. create a new object which uses that nif. Then placeatme that on the player. Then use PlaceAtNode() or MoveToNode() on that object to place the door at that node.

 

You can then even use that object as the return marker for the player. Just moveto him to it. Maybe even add a second node to mark where the player will appear at.

 

Mathful approach:

move the door to the player first so that it's in the proper interior cell/worldspace.

then:

door_X = r * sin(player.getAngleZ())

door_Y = - r * cos(player.getAngleZ())

door_angle_Z = player.getAngleZ()-180

 

This is done under the assumption that if the player's Z angle is 0, he's watching towards the negative Y axis. And that in F4, the Z axis is the vertical one.

 

For the player to return, you'd need to spawn/moveto something to the player's position before movetoing him into your interior (I presume). Then just moveto him back to that marker. Maybe also set the marker's angle to be player.getAngleZ()-180 so that he faces away from the door. Don't change the player's position or orientation after movetoing, that will create a second load screen.

 

 

BTW, this belongs in here, I think: https://forums.nexusmods.com/index.php?/forum/3935-fallout-4-creation-kit-and-modders/

could a kind mod move it there?

Link to comment
Share on other sites

Silly question maybe what is r ???

 

 

Mathful approach:

move the door to the player first so that it's in the proper interior cell/worldspace.

then:

door_X = r * sin(player.getAngleZ())

door_Y = - r * cos(player.getAngleZ())

door_angle_Z = player.getAngleZ()-180

 

 

Link to comment
Share on other sites

Ok I had post an issue here with the sin and cos not working but I managed to figure that out.

I'm not going to try to see if what you gave me helps. Either way I am very Grateful for your help.

Edited by silhouett
Link to comment
Share on other sites

Ok here is what I have so far, The door will appear in front of the player no matter how he turns, that's great.
however its rotation is that the thin side of the door faces the player and not the flat side you would enter a door through.
So I was playing a bit with the angel command and have not got that right yet. Code I have below


;code that I derived from your example
Float fAngZ = Game.getplayer().getAngleZ() ; Rotation of player to be used to place door in front or rear of player
Float Distance = 100 ; how far away from player
Float zOffset = 0 ; how high off ground
TheDoor = Game.getplayer().PlaceAtMe(COB_SPECIALBldWoodPDoor02) ; get actual door
TheDoor.moveto(Game.getplayer(),(Distance * math.sin(fAngZ)),(Distance * math.cos(fAngZ)), zOffset, True); positions door to Player
;What I have added to try to fix angle of door
Float DoorRotationX = TheDoor.GetAngleX()
Float DoorRotationT = TheDoor.GetAngleY()
Float DoorRotationZ = TheDoor.GetAngleZ()
TheDoor.SetAngle(X+ 90, Y+ 90, Z )

distance you want to have between player and door.

Link to comment
Share on other sites

That just means, the door's default orientation is like this.

And it seems like you did everything besides the right thing :D

It should be the Z angle:

TheDoor.SetAngle(X, Y, Z+90)

 

Maybe try -90, if the door is facing the wrong way.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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