How to spawn actor on drop

hi everyone I am trying to make an inventory system for a zombie game and have basic drag and drop working but it will not spawn the item on drop it just does nothing any help is appreciated thanks in advance

here is the screen shot of the code:

is your function actually called? thats the first thing id check, place a print string in there somewhere to test. then i would see if the spawn is occurring. the item will show in the world outliner if it is. if the item is spawning then its a issue with the spawn location. from what i remember with a system like that you actually need to project the cursor into the scene. the way you have it set doesnt work the way you think it would, what it does is it will spawn the item where the camera is but its exact position will be offset by pixel location, its weird and i may not be remembering it 100% right. but anyways check to be sure the function is being called and that the item isnt just spawning in an unexpected location.

I just tried checking with a print string and it printed the string I just don’t know where it’s spawning because the transform is set to spawn at the player location any ideas?

sorry never mind it was before but it’s not just realised… whoops

and what do you mean by project the cursor into the scene?

and if I do it without drag and drop but with the player location it won’t work unless the item is equipped

what i mean by project into the scene is that the mouse location to world space gives you a location in world space but that location is where the camera is. so what you need to do is use the world direction to give the location depth information. what i propose will in essence project a line from the camera out into the world x number of units and that is where you want to spawn your items. the easiest method to show this would be to use a line trace and use the world location as the trace start and (the direction * 1000) + world location as the end point and turn debug lines on. then when you activate the trace the line it draws will be from the camera to where you would expect the cursor to be if it were projected into the world. this same method works for the spawn except that you will want to decrease the value from 1000 to something lower so your item gets dropped near the player.

im assuming here that you are dragging items from the inventory into the world and that you are wanting the item to drop in front of the player.

the picture below shows a quick test method for this.

I tried it like the picture but instead with line trace first then spawn the actor at that location but for some reason it keeps spawning under the landscape and I have no idea why. any ideas what to do?

I also tried it in the player character with a key binding (so on enter pressed) and it worked so I don’t understand why the widget one won’t work

I’m just going to try this tutorial:

although it’s not drag and drop it still discards the items so I’ll see how that goes :slight_smile: