Jump to content

[Solved] I'm having trouble using Launchitem to return a traded item back.


Recommended Posts

local function OnGetItemFromPlayer(inst, giver, item)
	local x, y, z = inst.Transform:GetWorldPosition()
	y = 3

	local angle
	if giver ~= nil and giver:IsValid() then
		angle = 180 - giver:GetAngleToPoint(x, 0, z)
	else
		local down = TheCamera:GetDownVec()
		angle = math.atan2(down.z, down.x) / DEGREES
		giver = nil
	end
	
        item.Transform:SetPosition(x, y, z)
        launchitem(item, angle)
end

Here's what I've got so far, I want to return the original item back to the player, but this just places the given item into the prefab's inventory and then does nothing after. I'd like it to fling the item back out instead of simply refusing to take it in the first place.

Edited by Digi_056
changed code highlighting
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...