Pickup & Carry (uNet)?

I made a simple staff and threw it into the world, wrote a short script to make it so that a temporary animated character could pick the item up and carry it. This works flawlessly in a singleplayer context - that is, on the screen of the person that ran over the staff, the staff is being waved around with every minor move of the character, and I can make it swap from hand to back and … back.

However, on the screens of others, depending on what I’m trying at the time, the staff is there for other people to pick up and everyone has their own staff, but no-one else can see them, or the staff vanishes completely from everyone other than the holder, or… something equally bizarre.

No matter what settings I use, though, I can’t get it anywhere close to the desired result: Pick up and carry, while being visible to everyone. Think of it somewhat like a capture the flag concept, where everyone can see it, but only one person can grab it… and it’s very visible while it’s being traveled with.

I originally tried this with PUN and switched from Photon to uNet for a variety of reasons. Photon had exactly the same results, again depending on what I was trying at the time.

Some notes of the current state of it: I have a Network Identity and Network Transform on the staff. I’ve tried making it Local Player Authoritative (Which didn’t make sense at the time of trying it, since the staff itself wouldn’t have been ‘controlled’ in the traditional sense), and Server-Only (Which did what I expected it to: Hid it from everyone but the server-client).

Since the staff itself doesn’t have animations to speak of, it doesn’t have an animator or Network Animator. While I’m sure there’s something I need to be doing in a script to make it work, I haven’t the slightest (And haven’t been able to find anything throughout a night-long search which resulted in player-controlled characters being the issue, which isn’t the case here). The characters run around and animate (Via Mecanim) as intended at this stage.

In short, how do you make inanimate objects visible to all, collectible by one, and entirely wieldable/wearable over uNet?

Thanks!

After maaaany hours over the past couple of days of experimenting and poking at it, I’ve made (Some) progress on this. I finally found a StackOverflow post that was meant for people trying to spawn objects directly on characters and the issue turned out to be that the object wasn’t being added to the hierarchy server-wide, only for the client. Seems silly, but I never checked that until I’d read that post. That was the case.

Next, I went ahead and picked a staff up (Where a second staff would soon respawn when the client logged in) and logged in with a client, where I was able to see the host’s character wandering around with the staff perfectly fine.

However, when the client picked it up, it refused to have the same impact. After a ton more fiddling, I discovered the reason was because I couldn’t trigger a Command from the client’s main character.

I have a script called ‘Character’ on the character prefab (Root of it) that I have automatically spawn by the uNet Manager, and it says: “Trying to send a command for object without authority.”

My questions would be:

  • Is the manager not supposed to give authority to the players it spawns in?
  • How would I go about fixing that problem? Is there a particular function I need to override to give authority before it spawns?
  • Or is there something super-obvious I’m just missing?

Notes:

  • Local Player Authority is active on the character prefab
  • Network Identity, Network Transform, and Network Animator are on the prefab
  • The script I’m trying to call my Cmd from is also on the character prefab
  • I’m not custom-spawning the prefab, instead letting uNet spawn it in for me at the spawn point