Raised This Month: $ Target: $400
 0% 

Teleport an entity in front of a player?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Beaverboys
Member
Join Date: Aug 2012
Old 10-18-2015 , 20:39   Teleport an entity in front of a player?
Reply With Quote #1

I feel like this is some very basic trig that I can't figure out. I want to use a players origin and angles to teleport an entity 36 units in front of them. Could somebody provide some example code?
Beaverboys is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 10-18-2015 , 20:51   Re: Teleport an entity in front of a player?
Reply With Quote #2

This is used by zprops
PHP Code:
AddInFrontOf(Float:vecOrigin[3], Float:vecAngle[3], unitsFloat:output[3])
{
    new 
Float:vecView[3];
    
GetViewVector(vecAnglevecView);
    
    
output[0] = vecView[0] * units vecOrigin[0];
    
output[1] = vecView[1] * units vecOrigin[1];
    
output[2] = vecView[2] * units vecOrigin[2];
}
 
GetViewVector(Float:vecAngle[3], Float:output[3])
{
    
output[0] = Cosine(vecAngle[1] / (180 FLOAT_PI));
    
output[1] = Sine(vecAngle[1] / (180 FLOAT_PI));
    
output[2] = -Sine(vecAngle[0] / (180 FLOAT_PI));

__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick is offline
zipcore
Veteran Member
Join Date: Mar 2010
Location: m_flZipcore
Old 10-18-2015 , 20:57   Re: Teleport an entity in front of a player?
Reply With Quote #3

Quote:
Originally Posted by KissLick View Post
This is used by zprops
PHP Code:
AddInFrontOf(Float:vecOrigin[3], Float:vecAngle[3], unitsFloat:output[3])
{
    new 
Float:vecView[3];
    
GetViewVector(vecAnglevecView);
    
    
output[0] = vecView[0] * units vecOrigin[0];
    
output[1] = vecView[1] * units vecOrigin[1];
    
output[2] = vecView[2] * units vecOrigin[2];
}
 
GetViewVector(Float:vecAngle[3], Float:output[3])
{
    
output[0] = Cosine(vecAngle[1] / (180 FLOAT_PI));
    
output[1] = Sine(vecAngle[1] / (180 FLOAT_PI));
    
output[2] = -Sine(vecAngle[0] / (180 FLOAT_PI));

better use this:

PHP Code:
stock void AddInFrontOf(float vecOrigin[3], float vecAngle[3], float unitsfloat output[3])
{
    
float vecAngVectors[3];
    
vecAngVectors vecAngle//Don't change input
    
GetAngleVectors(vecAngVectorsvecAngVectorsNULL_VECTORNULL_VECTOR);
    for (
int i3i++)
    
output[i] = vecOrigin[i] + (vecAngVectors[i] * units);

__________________
zipcore is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:08.


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