How do i get the entity behind me?

I know the title might say it all. Because it does.

There is entity:GetForward() but now Entity:GetBackward.

What can i do to get the entity behind me.

Multiply what you get from get forward by a negative number to go backwards.

-snip-

Hi,

Just to clarify, Entity:GetForward() actually “Returns the forward vector of the entity, as a normalized direction vector” instead of the entity in front. If you wanted to get the entity in front you’d have to use util.GetPlayerTrace( Player ply, Vector dir=ply:GetAimVector() ) and perform a trace. This can also be used to get the entity behind a player. If you wanted to get an entity behind a player, you’d use the following code:


local entityBehind = util.TraceLine( util.GetPlayerTrace( player, -player:GetAimVector()) ).Entity

entityBehind will now contain nil or the entity behind the player if one exists.

You can use tracelines and make one that goes in the opposite of your eye direction ny using a negative number.