AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved TeleportEntity function? (https://forums.alliedmods.net/showthread.php?t=312731)

desire worker 12-14-2018 09:55

TeleportEntity function?
 
1 Attachment(s)
I saw the Wiki first but didn`t understand well. my code is working crazy now due to this function.

--------------------------------------------------------------
Syntax:
native TeleportEntity(entity, const Float:origin[3], const Float:angles[3], const Float:velocity[3]);

Usage:
entity Client index.
origin New origin, or NULL_VECTOR for no change.
angles New angles, or NULL_VECTOR for no change.
velocity New velocity, or NULL_VECTOR for no change.
--------------------------------------------------------------

Grasping meaning of entity, origin is fine but the others make me confused

suppose that there are 3rd dimensional vector space.

and wanna move 'client' in vector CP(x1, y1, z1) to vector DP(x2, y2, z2)

https://forums.alliedmods.net/attach...1&d=1544798809

then the code be the below because we wanna teleport 'client' to
designated position DP(x2, y2, z2)


Code:

TeleportEntity(client, DP);
but what is angle vector and velocity vector?

I was think below two things for each but neither was wrong.

angle vector : view direction of client after teleport? or direction vector during teleport?
velocity vector : velocity during teleport? velocity of client after teleport?

Fyren 12-14-2018 11:59

Re: TeleportEntity function?
 
They set the direction and velocity. It could be broken up to three separate functions (SetPosition, SetAngles/Direction, SetVelocity), but the function in the game itself is just one so it was left the same.

eyal282 12-14-2018 12:35

Re: TeleportEntity function?
 
DP[0] = Position on the X axis ( left and right )
DP[1] = Position on the Y axis ( front and back )*
DP[2] = Position on the Z axis ( up and down ).

Without regard, there are angles, where in space should the player look. I find it hard to grasp why isn't there just up and down, left and right ( 2 total dimensions ) but I'm not that of an expert on vectors.

And Velocity means speed + direction, that looks like Origin.

So if you give a player Velocity[2] = 1000.0;, he'll fly up. -1000.0 and he'll launch down.

* I might confuse X and Y, one of them is the other and I don't remember, and they can change by player perspective.

impossible_cc 12-14-2018 13:36

Re: TeleportEntity function?
 
If you want to just teleport from one coord to another one without changing angles (Camera position), according to your code you should do like this:
PHP Code:

TeleportEntity(clientDPNULL_VECTORNULL_VECTOR); 

Example of usage angles.
If you want teleport one player to any other player, you probably want to set his crosshair in the same place to crosshair of that second player.
Then you can do:
PHP Code:


void TeleportToPlayer
(int targetint otherPlayer)
{
    
float otherPlayerOrigin[3];
    
float otherPlayerAngles[3];
    
    
GetClientAbsOrigin(otherPlayerotherPlayerOrigin);
    
GetClientEyeAngles(otherPlayerotherPlayerAngles);
    
    
TeleportEntity(targetotherPlayerOriginotherPlayerAnglesNULL_VECTOR);


By the way, angles have only 2 dimensions. X and Y. ang[2] (z) always equals zero.

desire worker 12-14-2018 20:24

Re: TeleportEntity function?
 
Ok, It was indicating properties after teleport, now I got it thanks you guys


All times are GMT -4. The time now is 01:30.

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