Syncing spawned object

First i want to apologize that my English isn’t good, so i just go straight to the problem.

The ball is spawned with a BallSpawner and has registered as spawnable in Network Manager.

Say the ball original position is on 0,0,0.
From the server side i can pick, move and throw the ball just fine.
If i pick the ball from the client and move, the ball will started glitching (looks like it tries to lerp back to 0,0,0), and if i throw it the ball will just lerp back to 0,0,0.

What i’m trying to do is to get the client to be able to pick and throw the ball normally like the server.
I also provide the ball’s NetworkIdentity and NetworkTransform setting in the attachment.

Thanks.

Here’s the Ball script.

using UnityEngine;
using UnityEngine.Networking;

public class Ball : NetworkBehaviour, IPickupable, IThrowable
{
    public int itemScore = 1;

    void OnCollisionEnter(Collision other)
    {
        IScoreable scoreable = other.gameObject.GetComponent<IScoreable>();
        if (scoreable != null)
        {
            scoreable.Score(itemScore);
        }
    }

    public void Pickup(){}
    public void Throw(){}
}

Here’s the pick method.

void Pick()
    {
        if (!isLocalPlayer)
            return;

        if (!carrying && Input.GetButtonDown(grabInput))
        {
            Collider[] hitColliders = Physics.OverlapSphere(pickupCenter.transform.position, radius);
            int i = 0;
            while (i < hitColliders.Length)
            {
                IPickupable pickupable = hitColliders[i].GetComponent<IPickupable>();
                GameObject pickedUpObject = hitColliders[i].transform.gameObject;
                if (pickupable != null)
                {
                    float distance = Vector3.Distance(pickedUpObject.transform.position, transform.position);
                    float lowestDist = Mathf.Infinity;
                    if (distance < lowestDist)
                    {
                        lowestDist = distance;
                        closestGameObject = pickedUpObject;
                    }
                    carrying = true;
                    carriedGO = closestGameObject;
                    carriedGO.GetComponent<Rigidbody>().isKinematic = true;
                    carriedGO.GetComponent<Collider>().isTrigger = true;
                }
                i++;
            }
        }
    }

And this is the spawner script.

using UnityEngine;
using UnityEngine.Networking;

public class BallSpawner : NetworkBehaviour
{
    public GameObject ballObject;

    void Start()
    {
        CmdSpawn();
    }

    [Command]
    void CmdSpawn()
    {
        GameObject instance = Instantiate(ballObject, transform.position, transform.rotation) as GameObject;
        NetworkServer.Spawn(instance);
    }
}

2522301--174889--ball networkidentity.JPG

You need to be sending an updated position to the server from the client or calculating it on the server-side

Sorry but i’m still extremely new to unity networking so i’m not sure how to do that. Can you give me an example?

Thanks.

Anyone?

Have you read this yet?

I think i already read that before but i just read it again and this time i do as the “Non-Player Object” section told me but the problem is still here.

i have no problem with the players moving around. For the shooting and killing enemies part, i already test that on other test project without any problem.

I’ve also been looking around YouTube for tutorials but most of them are dealing with spawning players and make them not moving together with the same input. Some are more in depth and teaches about enemies spawning but i don’t think i can apply the same logic for grabbable object since the enemies are moving around by themself.

Okay, can you try this sample project I made? This deals with spawned non-player-prefab objects and syncing their movements. But I don’t know if this applies.

Another thing to be aware of is my example code here that teaches you what your code format should look like for dealing with objects through the network.

Hello.
Sorry for not replying for few days, i’ve been learning about your example for the last few days and now the ball is synced but the client still can’t pick the ball.
In other project it worked when i put [command] above the kick method, but it’s a much simpler code so i probably needed to to something different here but i don’t know what to do. So could you take a look at my project and tell me what went wrong?

here’s the project file.
https://mega.nz/#!5w8ggLSI!psguuKXHxISoi414qzcc8EpWgmqN6qni7WZLfODiHKg

That would qualify for a new thread, therefore I recommend you post a new thread. And please do not post mega links. I can’t download them here, and maybe others may not be able to. Instead, you should copy/paste your code with the forum post formatting provided, and start from there.