Set a position in front of player?

I’m unsure on how to set a position in front of a player with some distance, I’m working with a vector. Does anyone know?

local pos = ply:GetForward() * distance

I can’t seem to make this work. I am trying to set a position a foot away from a bot’s face, Instead the DrawLine goes way off.

With all the lines drawing to the same place it makes me think that might be the origin (0, 0, 0) and your code isn’t doing what you think it is.

Alright thanks.

How about you simply forgot to add the player’s position?

You probably meant this:

[lua]local pos = ply:GetShootPos() + ply:GetForward() * distance[/lua]

This is what I have.



		local pos = b:GetShootPos() + b:GetForward() * 100
		local pos2 = pos:ToScreen()
			
		surface.DrawLine( headpos.x, headpos.y, pos2.x, pos2.y )

We dont know what headpos is. You only show the locals for pos and pos2

‘headpos’ is the position of the head in the photo.

[editline]25th October 2013[/editline]

What killburn suggested seems to work, but I’m not sure how to point it in the front direction of the players.

[editline]25th October 2013[/editline]

Well thanks everyone, What I’ve got right now is good. I’m sure i’ll figure this out.

If you mean the direction in which they are aiming, try using GetAimVector instead of GetForward.