WorldToLocal problem

Hello facepunch. I am trying to get vectors for passenger seats (making some vehicles). I figured out how to set the vehicle’s angles to 0 0 0, but now I need to get the seat pos. I amde this script

function FindPlayer ( string )
local i = 0
local ply

for k, v in pairs ( player.GetAll() ) do
if string.find ( string.lower ( v:Name() ), string.lower ( string ) ) then
i = i + 1
ply = v
if ! i==1 then
ply = NULL
return ply

function Nig( ply, cmd )
Entity:IsValid then
MsgN ( ply:WorldToLocal( Vector ( tr.Entity )))

concommand.Add("getpos1", Nig )

As you can probably see, I don’t know how to make the script find the needed entity. I tried player eye tracelines, but failed. The position script gives me is counted from the center of the map, while I need to make WorldToLocal count it from the center of the car. Please help, I ran out of ideas.

What are you trying to achieve? Do you want to get the distance from the center of the vehicle to a seat?

Exactly. I noclip to the place where seat is supposed to be and find out the position, then put that into vehicle lua file.

Think this is what you want:

–V represents the vehicle entity
–S represents the seat entity
V:LocalToWorld(V:OBBCenter()) – Gets the world vector of the CENTER of the vehicle

S:GetPos() – Gets the world vector of the seat

V:LocalToWorld(V:OBBCenter()):Distance(S:GetPos()) – The distance between the two

Oh thank you man!

[editline]3rd July 2011[/editline]

The only problem is that I need all the vectors, not distance, but this one I can fix myself.