Author Topic: Making your player aim at a position  (Read 1557 times)

on the client side

How do I do this?

Look at a defunct aimbot, the code should be all there for actually making the player look at a given position

There have been other threads like this too, nexus wrote a quick code snippet in one of them

Being somewhat complicated trigonometry, I find this an acceptable place to spoon feed.

Code: [Select]
%pos="0 0 0";
%fv=ServerConnection.getControlObject().getEyeVector();
%x=getWord(%fv,0);
%y=getWord(%fv,1);
%vv=vectorNormalize(vectorSub(%pos,ServerConnection.getControlObject().getPosition()));
%xx=getWord(%vv,0);
%yy=getWord(%vv,1);
$mvYaw=mATan(%xx,%yy)-mATan(%x,%y);
$mvPitch=mATan(getWord(%fv,2),mSqrt(%x*%x+%y*%y))-mATan(getWord(%vv,2),mSqrt(%xx*%xx+%yy*%yy));

Being somewhat complicated trigonometry, I find this an acceptable place to spoon feed.

Code: [Select]
%pos="0 0 0";
%fv=ServerConnection.getControlObject().getEyeVector();
%x=getWord(%fv,0);
%y=getWord(%fv,1);
%vv=vectorNormalize(vectorSub(%pos,ServerConnection.getControlObject().getPosition()));
%xx=getWord(%vv,0);
%yy=getWord(%vv,1);
$mvYaw=mATan(%xx,%yy)-mATan(%x,%y);
$mvPitch=mATan(getWord(%fv,2),mSqrt(%x*%x+%y*%y))-mATan(getWord(%vv,2),mSqrt(%xx*%xx+%yy*%yy));
yeah I thought it was quite complicated
Thanks for the code, I'll try to figure it out

I just tested the code and it doesn't work?

I every time I call the code with the same position he aims somewhere else
and it doesn't actually aim anywhere near the position

I don't really know whats wrong because I don't really understand the code :s

Never mind I switched getEyeVector() with getMuzzleVector(0) and somehow it works now
« Last Edit: July 29, 2013, 11:05:22 AM by Aide33 »

Oh yeah, my bad. I forgot that Badspot forgeted with getEyeVector, use getMuzzleVector.