Game Development Community

Getting a point in front of "eye

by Kirby Webber · in Torque Game Engine · 08/22/2005 (7:16 am) · 2 replies

What I'd like to do sounds very simple, but I can't seem to locate a function that will allow me to do this easily - therefore I'm asking the scripting gurus around here if they have any ideas.

I want to get a world location an arbitrary distance in front eye, for example, 60 units. I'm not sure how to go about this - is there a way to do this by simply adding to the eye vector or something similar?

Thanks in advance for any help.

#1
08/22/2005 (8:22 am)
Kirby

There are 2 console functions for shapebase objects, getEyeVector() and getEyePoint().

Something like this would probably work (assuming the eyevec is normalised? - if not there is a console fuction VectorNormalise(%vec) that will take care of it)

%eyeVector = %obj.getEyeVector();
%eyePoint = %obj.getEyePoint();

%scaledEyeVector = VectorScale(%eyeVector, 60);

%location = VectorAdd(%eyePoint, %scaledEyeVector);

Where %obj is the shapebase object that you want to use (always assuming it actually has an eyepoint in the first place)


Hope that helps.
#2
08/22/2005 (8:46 am)
Cool, I will try this when I get home tonight.

I was hoping it was something that simple.

Thanks David - much appreciated. =)