Hello ... as the title says, I want to calc a point perpendicular to vehicle. I have this code to calculate a point x units forward of vehicle ... local position = vec3(veh:getPosition()) local forward = vec3(veh:getDirectionVector()) local coordinate = forward * x + position But how to calc a point x units beside the vehicle? Much appreciate any help. Cheers!
IIRC, there's similar code to determine the vehicle's up vector. Combine the forward vector and the up vector with a dot product, and that should give you a position next to the vehicle. Edit: sorry, cross product. SineMatic has it right
Hey guys, thanks. That help me figure out how to calculate position left or right of vehicle position. local vecPosition = vec3(veh:getPosition()) local vecForward = vec3(veh:getDirectionVector()) local vecUp = vec3(veh:getDirectionVectorUp()) local vecRight = vecForward:cross(vecUp) local lr = (math.random() * 1.2) - 0.6 -- generate a random left/right offset local target = vecForward * fillSpot + vecPosition -- get inital location on trailer center (which doesn't appear to be centered left/right) target = vecRight * -0.5 + target --tweak position left target = vecRight * lr + target -- apply random offset left or right (positive or negative value)