Please or Register to create posts and topics.

Vscripts: player perspective vector [SOLVED]

PreviousPage 2 of 2

I may have some sort of weird solution for this if you also want the pitch.

  1. Force the player to create an entity such as an info_target (Ent_create info_target)
  2. Name this info_target (Ent_setname name)
  3. Get the coordinates from your origin + the units up to around your view/eye. According to the wiki this is 64 units.
  4. Get the coordinates from the recently named info_target
  5. Use the 2 point - angle formula in order to get the vector (angles xyz) from the player + 64 to the info_target.

Edit:
2013 ChickenMobile's idea is dumb - 2019 me came up with a much better way:

  1. Create an object you want to mimic player view angles from. This object must be non-solid and/or invisible.
  2. Create an info_target
  3. Create a logic_measure_movement
    1. Set Measurement Type to "Eye Position"
    2. Set Entity to Move to the name of your object
    3. Set Entity to Measure to !player (or wanted player's targetname).
    4. Set both Measure Reference and Movement Reference to the info_target.

The Forward vector can then be retrieved through:

Code: Select all
Entities.FindByTarget(null, "name_of_object").GetForwardVector()
?????????????????????????????TWP Releases | My Workshop

But doesn't ent_setname work like !picker in that it fails on non-physically-simulated objects, such as targets?

Falsi sumus crusto!

That's actually a very smart idea, Chicken! I messed around with this for a bit, and found a few things:

1) Naming the info_target isn't an option. Since ent_setname is naming what the player is looking at (we can't reference the created info_target directly), the script can actually pick up other ents. I discovered this when I accidentally deleted the very logic_script that was running this script. To fix this, I'm just using some entity that I'll never use in the level, and then finding it via Entities.FindByClassname().

2) Only certain entities work! Some entities only seem to work on flat, horizontal surfaces, and not walls. After experimenting for a while, I discovered that point_laser_target seems to work fine. Most prop_* entities work, but they cause other issues that I didn't want to deal with (missing models, console errors etc).

3) Instead of adding 64 to the z-component of the player origin, you can just take GetPlayer().EyePosition(). It's the same thing, but I thought you should know.

For those curious, here's the code:

Code: Select all
SendToConsole("ent_create point_laser_target");
while((ent = Entities.FindByClassname(ent,"point_laser_target"))!= null)
{
   playerLookPos <- ent.GetOrigin();
   SendToConsole("ent_remove point_laser_target");
}

playerLookPos <- Vector(playerLookPos.x,playerLookPos.y,playerLookPos.z-12.031);
//For some reason the z value is always off by that much, probably has to do with lolsourceengine

One issue is that it always lags behind one step since you can't get the ent's data until a little bit after it's been made, but it pretty much works.

==SOLVED==
(It's still possible that Valve will add the function I requested, but I'm not keeping my fingers crossed)

tl;dr:
Image

Nice! But nota bene: on the Workshop ent_create is a cheat.

Falsi sumus crusto!
FelixGriffin wrote:
Nice! But nota bene: on the Workshop ent_create is a cheat.

Not if you call it through a script?

Idolon, I was trying to get this to work with a cube to copy my angles and I pretty much got it working (with nearly the exact code you have with the checking of the null item in case it didn't spawn and spawning and deleting from a classname) except I had a major problem with mimicking the angles as the link I gave to you is actually only 2D not 3D (sorry).

So you will need to create a matrix in order to get the angles and do some other mathematics and normalizing manually as squirrel doesn't actually have any base vector functions built into the engine (which is incredibly stupid).

I think HMW made this with his sendificator script already, so give him a buzz.

?????????????????????????????TWP Releases | My Workshop

Actually, just having the coords of the player's eye and the player's look position are should be enough to accomplish what I'm doing. Thanks for the advice though!

im trying to do this same thing, but it keeps saying there is no such attachment.

What is the exact written attachment name?

Just when I think I understand the system, it changes on me.

What player model are you using? It should be "eyes" (four letters, lowercase, no quotes), but Bendy and possibly the robots lack it.

Falsi sumus crusto!

you mean its not the same for all of them?

EDIT, I tried this and i see how ridiculously jittery it is as mentioned before, not only that, but the entities ended up being pointed towards the ground.

Just when I think I understand the system, it changes on me.
PreviousPage 2 of 2