Help with spawning actor on pickup in VR

I hope I posted this question in the right section. I’m fairly new to blueprints and VR and this is probably an easy answer but any help would be appreciated. I tried searching online but couldn’t find an answer, hence posting here…

What I’m trying to do is create a “spawner” object in the world. When a player “picks up” the spawner object with their motion controller, instead of picking up the spawner object it spawns a seperate actor where the spawner object is and attaches itself to the controller grab sphere.

So let’s say there is a sword on the wall. The player goes to grab the sword. Instead of the sword on the wall attaching to the motion controller an identical sword is spawned with the same transforms as the spawner and is attached to the controller, leaving the spawner sword still on the wall.

The spawner object is a BP actor class and the object it will be spawning is a seperate BP actor class that share the same static mesh and material, the only difference between the two being the pickup functionality (spawner spawns instead of attaching and other is default pickup behavior).

I hope this makes sense, I’ll try to post a video later to demonstrate what I am looking for.

Thanks.

I did something like this with amino-acid meshes on a pedestal. A player would grab the amino acid, and the pedestal would animate to produce another one in its place. It was a long list of actions happening though.

A player would grab a dummy-mesh,
the dummy mesh would become hidden,
a locally spawned mesh would attach to the player and be marked with a “temp” boolean
a new mesh would spawn on the server and attach to the initiating player,
the temp mesh would be destroyed (purpose of the temp mesh was to appear seamless to the initiating player, not having to wait on server)
the pedestal would start its respawn animation (basically the middle of the pedestal would just sink in and then resurface)
the dummy-mesh would be unhidden

Because the pedestal exists in the level, it can be replicated to handle the spawning logic for you. I do recommend getting the server-side spawning working before trying to implement the local temp spawn

Thanks for the advice. I figured out how to do it. I hope this is an efficient way to do it because it works flawlessly otherwise.

In the “spawner” blueprint I added an InputAction for a trigger press. On the trigger press it casts to the motion controller and checks to see if it is overlapping the Spawner object (only the grab sphere collides). Then if true it spawns the identical object at the world position of the grab sphere and sets simulate physics to on.

The neat part (and unintentional feature I like) is that when you half press the trigger it spawns the duplicate item but does not attach, it just falls to the floor. If you pull the trigger fully it spawns the item and then the default “grab” function kicks in, attaching it to the controller.

1 Like