Help with vectors and angles...

Hi, I’m trying to make a functional and not glitched teleporting SWEP (for my server).
But there are some things I don’t know how to do.

I want to prevent the player of being teleported through walls, I got some ideas But I don’t know how to do them like Use the AimVector and the EyeTrace and do some mathematics to set the Vector of the SetPos so the player doesn’t get stuck in walls.

Also limit the Teleportation distance so when the player Aim in front of him (or far enough) he can only teleport his self 750 units forward.

And Finally the SWEP can directly teleport to the nearest player and kill him even if he is behind (the function is done, the question is just after =>), but I wanted to set the angle of the player so just before he is teleported, he automatically aims the player he is going to kill.

However like I said, I don’t know how to do these things so if you could help me :confused:

Thanks for answers !

Some functions I think will help you:

The idea is, trace a line of 750 units from the players position, in the direction of his aim vector.
If it doesn’t hit anything, teleport the player 750 units forwards.
If it hits something, get the distance or position where the trace hit, and teleport the player there.

If the trace hits a player, compare the 2 player’s aim vectors to determine if the person using the swep is behind them or not, and kill them (or not)

Use the traces HitNormal to get which direction the wall the tracer hit is facing and offset the position to teleport to by the players collision box relative to the origin of the player. E.g. shooting at the roof, the HitNormal would be pointing down and you should offset the position downwards by a full players height. I believe the origin of a player entity is right between the feet. So shooting the floor should not need an offset, the roof an offset of a full player height, and walls offset by half of the players width.

Actually, it’s funny but, I don’t know how to do anything of that :confused:
I’m a verrryyy newbie with Vectors and Angles you know :confused:

If someone could help me :stuck_out_tongue: