#Pick up and drop

73 messages · Page 1 of 1 (latest)

void folio
#

Soo I've been trying to do it for like 10 hours now, does anyone have a script for a single item pick up, carry and drop (seen by other players) that I could use as my base? Preferably upgradeable because I probably will change it a lot. 🙏

stable quiver
void folio
#

I tried it and I don't understand it and can't make it work

regal bolt
#

I don't really have a drop item setup yet but for pickup and storing I simply have two scripts, ItemPickup and PlayerInventory

I simply use rayCast to get the Collectable Object and then destroy it on network after I add it to the SyncList in my PlayerInventory (You can use SyncDictionary).

And for the drop I guess just remove it from the PlayersInventory and Spawn it using NetworkServer.Spawn()

Make sure you mark your prefab as registered prefab

void folio
stable quiver
void folio
#

how do i change like the 1 2 3 inventory into a single item pick up and hold?

void folio
#

also in the network manager should i add anything tot he spawnable prefabs?

stable quiver
#

If you don't need to keep track of anything like ammo or similar for the dropped thing, you can just make an art prefab to show locally in hand, and a variant prefab for the dropped object that has a network identity on it.

void folio
stable quiver
#

click the items on ground to pick up

void folio
#

i can pick up some items only

#

and i can still spawn infinite ammount of them

stable quiver
#

sure, that's just how the example is made - you don't have to have that part

void folio
#

oh alr

#

but still the pick up is very broken

#

should it be that way?

#

like i have to spam click to sometimes pick an item up but only like 1/4th of the items is pickable

stable quiver
#

It's really not - I can pickup every single item dropped

void folio
#

do you know what might cause this issue?

stable quiver
#

no idea. What version of Unity?

void folio
#

i put the script onto my player and setup everything like on the prefab and everything else i took from the prefabs

#

2022.3.60f1

#

unity version ^^

stable quiver
#

It's just this

void OnMouseDown()
{
    NetworkClient.localPlayer.GetComponent<PickupsDropsChilds>().CmdPickupItem(gameObject);
}
#

maybe you have something else blocking the clicks?

void folio
#

what could it be

#

empty game object counts?

stable quiver
#

probably not, but UI maybe

#

I know for sure the example works perfectly

void folio
#

i dont have any ui

#

maybe the player itself but shouldnt, right?

stable quiver
#

obviously the scene object needs a collider of appropriate size

void folio
#

the capsule which the player has as a child

void folio
#

i just copied it from the prefabs into the network manager as a spawnable prefab

#

can i raise the pick up range somewhere?

stable quiver
#

In the example the child art has a collider on it...that's required

void folio
#

i copied everything from the example so shouldnt it work?

#

im not really familiar with the english names, could you quickly explain what "child art" is? You seem to use it a lot and i have no idea what it is

#

can only assume its the child of a player

stable quiver
#

In the example, Ball, Bat, Box are art objects. They're instantiated as child art of the hand when held or as child of Scene Object prefab when spawned

#

Scene Object has a Rigidbody, and Ball, Bat, Box each have a correct collider

void folio
#

wait

#

sceneobject has rigidbody?

stable quiver
#

yes, you can see that

void folio
#

nvm it does

#

i can pick up the items only when im walking on them and are lucky

#

but i managed to pick up every item

#

so every item is pickable but something is blocking

#

couldnt be the body of a player, right?

#

maybe its a low pick up range

stable quiver
#

collider is art prefab scaled too small?

void folio
#

not pick up range becasue i made my player really tiny and he still struggles

stable quiver
#

this is basic debugging, really - examine everything in the editor for correct scale

void folio
#

i made every collider twice as big as it should be and it worked perfectly

#

but doesnt work with the correct collider size

#

i set the collider size to 1.1 instead of 1 and no problem at all

#

should i just keep it that way?

#

all right its all bugged

#

i raised my player height back to normal and cant pick it up again

#

even with big colliders

#

it has to have big colliders and my player has to be short for it to work on my project

#

no idea what is happening

#

i guess something is wrong with my player

#

capsule has a hitbox and everything else is empty gameobjects

#

player has rigidbody