Author Topic: Getting what you are aiming at client-side  (Read 1198 times)

Basically, /title. Is there a way to get the object of what I'm looking at on the client side? I tried using
serverConnection.getObject(%i).getTransform() and seeing if it was close to serverConnection.getControlObject().getTransform();, but then there's the problem of having something close to you but not directly in front of you.

You can get your eye vector pretty easily, even though Badspot technically disabled it to prevent aimbots. The problem is that once you do get your eye vector, you can't shoot out a raycast to get the object you're looking at.

Unfortunately, it's not possible to detect the object you're looking at.

You can get your eye vector pretty easily, even though Badspot technically disabled it to prevent aimbots. The problem is that once you do get your eye vector, you can't shoot out a raycast to get the object you're looking at.

Unfortunately, it's not possible to detect the object you're looking at.
Not through plain torquescript, at least.

The screenshot-aiding getFocusDistance function will tell you how far away the object you're looking at is. You could then use the looping you mentioned to find out what is infront of you, but remember it won't be efficient.

The screenshot-aiding getFocusDistance function will tell you how far away the object you're looking at is. You could then use the looping you mentioned to find out what is infront of you, but remember it won't be efficient.
Oh, thanks. That's pretty cool! Idea - use this and then use maths to figure out if it's in my FOV (so the distance between the object behind you won't get returned), and then loop through serverConnection. But is there a better way to do this? Because having 50k serverConnection child objects and looping through them is going to take forever lol

You might want to consider starting from the back of ServerConnection instead of the front.

You might want to consider starting from the back of ServerConnection instead of the front.
So starting at the count going to 0 instead of starting at 0?
Like
for(%i = serverConnection.getCount(); %i > 0; %i--)

instead of

for(%i = 0; %i < serverConnection.getCount(); %i++)

?
Is there a reason why I should do this (eg efficiency, proper way, etc)?

i suppose it depends from server-to-server, but the objects you're probably looking for might be closer to the back than the front in many cases

esp things like players that respawn and whatnot often

I'm actually looking for bricks, but I suppose that would have the same effect? Nevermind, the bricks don't get an entire new objectID when they respawn. But anyways, would that still apply for looking for bricks?

i imagine functionally it would have no effect

you could do some incredibly hard math to figure it out but that is so hacky it's not even funny