Normalized Vector problems

[lua]local angle = v:GetPos() - p:GetPos()
print(angle:Normalize()*1000) --attempt to perform arithmetic on a nil value[/lua]
angle isn’t nil and printing angle:Normalize() result in empty line. What the hell am I doing wrong?

I think you need to do
[lua]
local angle = v:GetPos() - p:GetPos()
angle = angle:Normalized()
print(angle*1000) --attempt to perform arithmetic on a nil value
[/lua]

That’s for the vectors anyways.

Normalize normalizes an angle/vector directly, without returning a value. GetNormal creates a copy of that angle or vector, normalizes it, and then returns it. Normalized probably does the same thing too, I’ve always used GetNormal but it’s probably one of those function aliases.

Weird though. I looked back at a gamemode where I used the same exact method to push NPCs or Objects towards a Vector and it worked fine.

Now I get attempt to perform arithmetic on local ‘angle’ (a nil value) when printing angle after the :Normalize()

[lua]
print( ( v:GetPos() - p:GetPos() ):GetNormalized() * 1000 )[/lua]

Now you gotta tell me why the hell this works.

Or you could open your eyes and see for yourself. Vector:Normalize() doesn’t return anything since we moved to GMod 13. Vector:GetNormalized() does.

Oh, Thanks. Great to know.