How to spawn an entity in a position in relation to the players positon.

So, back again, and pretty much last question. So I have the ship that is able to spawn when the button presses, but I don’t know how to make this spawn in a certain point a few feet away from the player, here is my current function for it.


net.Receive("BuyDelta", function(len, ply)
	entity = ents.Create("delta-7")
		entity:Spawn()
		entity:SetPos(ply:GetPos())
		
		timer.Simple( .25, function() 	
			PrintMessage(HUD_PRINTTALK, "Your ship has been delivered.")
	end)
	end))

Any help with the right hook or function or anything I need to put to get a slightly different position than ply:GetPos, will be greatly appreciated.

Set the position before spawning the entity, not after. I should also add you can use Vector to make it spawn a few feet away from the player. Not sure if that is the best/correct way of doing what you want.

But where would I set the spawn point to?

I’ll give you an example of what I have for my car dealer:



		if game.GetMap() == "gm_flatgrass" then
			ent:SetAngles(Angle(0, 90, 0))
			ent:SetPos(Vector(357, -44, -12224))		
		end


Granted, this might not be the best way of doing it, but, it is good nonetheless. As you can see I have the game.GetMap as I use several maps and would like to have a set spawn point for the npc (which is not what the code is) and a set point for the vehicle as I already have a set spawn point for the npc (which is what the code is shown).

It just says its ridiculous basically and deletes.
I just want it to spawn like 5 feet to the right of the player who called it to be spawned.

This should do it.


local ent = ents.Create("ent_item")
	ent:SetPos(ply:EyePos() + ply:GetAngles():Right() * 64 + Vector(0, 0, 20))				
	ent:Spawn()

64 is the distance, we then add 20 units of height so the item doesn’t clip the ground.

Use

Angle:Forward if you want the item to spawn to the front/back of the player.

Thanks dude! I just had to change the values a little bit but other than that it worked!