# Getting oriantional velocity of an entity?

I’ve done it before, just don’t have any scripts that i wrote it on and don’t exactly remember.

How to get entitys forward/right/up velocity individually?

Relative to the entity, I guess?

[lua]local vel = self:GetVelocity()
local fw_vel = vel:Dot(self:GetForward())
local rt_vel = vel:Dot(self:GetRight())
local up_vel = vel:Dot(self:GetUp())[/lua]

Also, the dot product of two vectors is a number, keep that in mind.

Yeah. Seen Dot() before. But never quite understood it and the wiki doesn’t help either. Could you give a description of it or something please?

http://dl.dropbox.com/u/9104987/dotproduct.png

Though, I haven’t worked with the dot product in a few months, might be talking out of my ass.

Cool you even made a visual presentation I think i understand now, gonna do some more tests with it in gmod. But yeah. Thanks.

Wouldn’t that be Vector:Length() ?

Yeah, i also thought that he was confusing it with Vector.Distance().

The difference is that the dot product exists outside of gLua, length and distance don’t IIRC.

You’ve got dot way wrong, you’re doing basically (vec1+vec2):Length()

[editline]11:24PM[/editline]

And what are you on about, length exists in vector maths: ¦vec¦

Ah well, it’s been 5 months since I last used it, even then only passing with a C.

Am now reading up on it.

Am I right in saying it’s x1x2 + y1y2 + z1z2?

Nevermind, just read the wiki page and realised above is correct.