Thread: Teleport entity
View Single Post
Balimbanana
Member
Join Date: Jan 2017
Old 11-16-2019 , 12:24   Re: Teleport entity
Reply With Quote #4

In that case, it will need to be calculated. There are a couple ways to do it, here is a somewhat simple version:
Code:
g_fLocation[0] = (g_fLocation[0] - (10 * Cosine(DegToRad(g_fAngles[1]))));
g_fLocation[1] = (g_fLocation[1] - (10 * Sine(DegToRad(g_fAngles[1]))));
g_fAngles[1]+=90.0;
g_fLocation[0] = (g_fLocation[0] + (10 * Cosine(DegToRad(g_fAngles[1]))));
g_fLocation[1] = (g_fLocation[1] + (10 * Sine(DegToRad(g_fAngles[1]))));
g_fAngles[1]-=90.0;
TeleportEntity(entity, g_fLocation, g_fAngles, NULL_VECTOR);
There is a way to do it in one calculation, but this is accurate enough.
It will move the location backwards relative to the angles.
+90 will rotate left.
Then move forwards (relative to new ang) 10.
Then -90 to return angs then teleport.
Balimbanana is offline