AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Getting origin in front of player (https://forums.alliedmods.net/showthread.php?t=12362)

XxAvalanchexX 04-13-2005 16:31

Getting origin in front of player
 
What is/are the mathematical formula(s) for getting the origin directly in front of the player?

Twilight Suzuka 04-13-2005 21:19

Try this:

Code:

public get_oriented_origin(id,Float:fDistance)
{
        new Float:nOrigin[3]
        new Float:vAngles[3] // plug in the view angles of the entity
        new Float:vReturn[3] // to get out an origin fDistance away


        entity_get_vector(id,EV_VEC_origin,nOrigin)
        entity_get_vector(id,EV_VEC_v_angles,vAngles)
       
        vReturn[0] = floatcos( vAngles[1], degrees ) * fDistance
        vReturn[1] = floatsin( vAngles[1], degrees ) * fDistance
        vReturn[2] = floatsin( -vAngles[0], degrees ) * fDistance

        vReturn[0] =+ nOrigin[0]
        vReturn[1] =+ nOrigin[1]
        vReturn[2] =+ nOrigin[2]

        return 1;
}

It may or may not work. First, it gets the angles and gets the vector direction they are looking in, multiplies it to get a specific distance, and then adds it to their origin.

Give it a shot.


All times are GMT -4. The time now is 09:49.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.