Please or Register to create posts and topics.

Vscripts: player perspective vector [SOLVED]

Page 1 of 2Next

I'm currently working on a Vscript to determine a vector that describes the direction the player is looking in. While I can find the X and Y values from using GetPlayer().GetForwardVector(), this doesn't return the Z value (it is always 0). Does anyone know how finding the Z value could be accomplished?

EDIT:
I've solved the issue in a fairly roundabout way with help from ChickenMobile! You can grab the code a few posts down.

Can't you just parent some trigger looks to the player and some info targets that are up, down, front, and back? That's probably how I would do it.

My YouTube Channel: https://www.youtube.com/user/Camben24
Aperture Science: We do our science asbestos we can!

I need an exact number for my uses, unfortunately. However, I do have an alternative idea. Would it be possible to use !picker (or something similar) to find a vector of where the player is looking, relative to the world?

Not unless the player is looking at an appropriate scripted object at all times.

If you SetParentAttachmentMaintainOffset something to the !player's "eyes" attachment it moves when they look. You could do that with two info_targets at different distances and subtract their position vectors relative to the player, that would give you what you need.

Falsi sumus crusto!

Parenting to the player's eyes sorta works, but since it's a literal attachment to the "eyes" bone of the player model, it jitters around a lot. I'll e-mail Valve and see if I can get a better solution, and if not, I'll use this technique. Thanks!

Wouldn't it be better to get the player angles so you know exactly what way they are looking?
The angles go from 180 to -180 so it would take a little bit to get used to.

Code: Select all
local PlayerAng = player.GetAngles()
local PlayerDir = PlayerAng.z
printl(PlayerDir)
?????????????????????????????TWP Releases | My Workshop

Does that return the Z value, though? I didn't think it did.

Falsi sumus crusto!

It doesn't, unfortunately. Looking up and down doesn't change the player's pitch.

Totally offtopic: Idolon; what objects are you hiding...

Giant stashes of stolen door from various door-less maps.

My YouTube Channel: https://www.youtube.com/user/Camben24
Aperture Science: We do our science asbestos we can!
Page 1 of 2Next