Item drops but isn't quite right

Hi,

The player character can pickup an item, the player can also drop an item, however, there are two issues I’m facing that I can’t rectify.

  1. The cube that is held doesn’t disappear from the players hands when the ‘G’ / drop key is pressed.

  2. When the ‘G’ / drop key is pressed, the cube falls through the floor a little bit.

Player BP

Cube Item Pickup

Thanks for any assistance!

Hi,for the problems right now only .you could try replacing the detach node with set static mesh.set it to none.

and why the cube enters ground a little,it’s probably the cube’s pivot point.make sure the cube actor’s center is at its button.

1 Like

Thanks for your help! it definitely gets rid of him holding it but no longer drops it, is there a guide you know of that is inclusive of pickup and drop for physics based items? or do you think this is salvagable?

1 Like

if its physics based, detach (assuming you are attached) enable collision, enable physics and possibly addimpulse in the actorforwardvector*x

you may also want to set the world location first incase it colliside with the owner when you enable physics

1 Like

Okay, so I have the following working well, except, it lands immediately on the floor at the base of the player and through the ground a little bit, but we have issue 1 resolved, which was to remove it from player hands when dropped!

I wasn’t sure where to change the collision settings on the BP or within the player itself

Player (Equipped Item static mesh)

The pickup item BP static mesh

I could enable physics on the item BP but not the Player (Equipped item static mesh)
image

1 Like

if your using physics you dont need to find the floor, gravity will :slight_smile: so for now remove the SetActorLocation.

what is your item ? if its an actor just detach it, dont set the staticmesh to null.

regarding collision,
when equipped you want to disable collision and physics or it will hit the owner
when unequipped enable collsion and physics

also using physics your static mesh should be the root component

Okay I’ve updated as you suggested, but now the cube still appears in the hands of the player and doesn’t drop

Item Pickup

Item Drop

Equipped item static mesh collision

  • the Item / Cube itself keeps falling through the floor before I can even get to it :frowning:
  • tested this on a different object with physics and it too falls through the map no idea why
  • cubes land correctly when resetting their Z value while playing, seems to only fall through map on startup?

Demostration

on item drop you didnt set physics enabled which is your error message there.

also when you detach keep world.

1 Like

Okay I’ve fixed that up but the static mesh itself still falls through map

collision setting for static mesh

resetting position make it act normally, not sure why it doesn’t on game start

I made the following change and it now appears correctly

We have the following remaining issues:

  1. Cube on ground doesn’t disappear when picked up from the ground
  2. The cube disappears from hands when dropping but doesn’t appear on the floor or anywhere
  3. Picking up the cube a second time where the box collision still remains causes the box to appear but larger and not in the hands of the player

Demonstration

Blueprint logic

1 Like

so what are you setting the static mesh for, its already set in world?

also for physics to work properly it needs to be the root component, you seem to have a mesh and a collision box, can we see the setup of your item

1 Like

The settings works for what the character is currently ‘holding’ or at least look like he is, I’m not sure what to do about the last bit you mentioned I’m not well versed in UE, it’s my first game for context sorry!

From what I can tell the static mesh itself does have a collision box on it, hopefully below helps

Static mesh

Collision box

Static mesh itself

drag the static mesh over the default scene component too make it root, then drag the collision box on the static mesh and ‘attach’

i assume the collision box is to detect if close enough to pickup, so make it query only and ensure its not set block any other collision channels

Okay, that is done and I can see improvement!

  • Object appears but it presents inside the player
  • Object doesn’t react with physics as it falls like I would expect, seems to land immediately
  • Object appears to duplicate itself somtimes

ok so since your socket is set to none it attaches to the root of the character, you’d have to create a socket on the skeleton in front of the mesh to make it appear like its being held.

you physics still isnt set properly so its not working at all. try get
equippeditem->getrootcomponent->setsimulate physics true.
also double check all the collision since you’ve moved everything around

Hmm, I tried to connect it to the set simulate physics but it won’t let me

collisions on equipped item

ah sorry it should be a of primitive type. too be honest all this should be done in the item itself anyway so i know its a bit of a pain but i’d recommend moving it all.

just create 2 functions in the itembase, pickup and drop and for testing purposes you can just use your interact interface call.

for now though since you’ve got a HardRef to the item you can just get the staticmesh and setphysicsenabled on that if you prefer.

also as ive said dont SetStaticMesh to null, you cant have collision on a null component

It creates the cube correctly and drops it but I can still see the weird cube from inside and I can only pick it up once the physics cube so I’m at a loss at this point.

Would it be too much to ask to recreate this somehow and show me how you did it? like you mentioned doing it all in the item itself?

Scrapping my initial logic, I followed this guide and seem to be getting closer to what I had in mind, although it’s too far from the player when picked up

the recreation cant have anything to do with the pickup/drop logic, check youre not spawning a duplicate or something in the item is having that effect.