Mariokart like game in unity and mirror

Viewed 24

Hi I have a question about mirror.

I have made a mariokart like game. it works almost perfectly I only have one problem I cant seem to fix.

when I shoot a weapon on the server it works perfectly. On the client it also works when I'm standing still. but when I do it on the client while driving it spawns behind the cart because of syncing or something. How can I fix this?

this is the code

    void Update()
{
    if (Input.GetKeyDown(KeyCode.Space) && hasItem)
    {
        hasItem = false;
        _icon.sprite = null;
        CmdFireWeapon();
    }
}

[Command]
private void CmdFireWeapon()
{
    GameObject item = Instantiate(tempItem, weaponSpawner.position, weaponSpawner.rotation);
    NetworkServer.Spawn(item);
}
0 Answers
Related