suriyun-production / mmorpg-kit-docs

This is document for MMORPG KIT project (https://www.assetstore.unity3d.com/#!/content/110188?aid=1100lGeN)
https://suriyun-production.github.io/mmorpg-kit-docs
49 stars 10 forks source link

Mount Issue #2581

Closed temel61 closed 1 month ago

temel61 commented 1 month ago

It calls wrong different mount when I click use button.

Ekran görüntüsü 2024-10-21 101759

insthync commented 1 month ago

What? it must ride easter cow, instead of bestial soldier?

temel61 commented 1 month ago

it must be summon nirvana dragon (Blue dragon).But it summon wrong vehicle.I added some debug.log in code.Why it always changing?.

temel61 commented 1 month ago

Ekran görüntüsü 2024-10-21 103929

insthync commented 1 month ago

You may try check if asset ID is difference or not in your vehicle entity -> LiteNetLibIdentity component

temel61 commented 1 month ago

It always calls last vehicle in the list. Ekran görüntüsü 2024-10-21 121726

insthync commented 1 month ago

Please do what I've told you.

temel61 commented 1 month ago

I will do that.But my only horses inluded in to addressableplayer prefab list.No camel, no alpaca,no tiger in the list.

Ekran görüntüsü 2024-10-21 123729 Ekran görüntüsü 2024-10-21 123810

temel61 commented 1 month ago

Ekran görüntüsü 2024-10-21 170815

insthync commented 1 month ago

I don't understand what the log is telling

temel61 commented 1 month ago

I use alpaca mount with HashAsassetId 372029326, but It found griffin with HashAsassetId 372029326, same key but different prefab in GuidToPrefabs.I think it create same HashAssetId for different entity or duplicate entity.

BaseGameEntity_MountFunction.cs

    public virtual async void Mount(VehicleEntity prefab, AssetReferenceLiteNetLibBehaviour<VehicleEntity> addressablePrefab)
    {
        if (!IsServer || (prefab == null && !addressablePrefab.IsDataValid()) || Time.unscaledTime - _lastMountTime < CurrentGameInstance.mountDelay)
            return;

        if (addressablePrefab != null)
        {
            Debug.Log("Start_Name : " + addressablePrefab.editorAsset);
            Debug.Log("Start_HashAssetId : " + addressablePrefab.HashAssetId);
            Debug.Log("Start_AssetGUID : " + addressablePrefab.AssetGUID);
        }

        _lastMountTime = Time.unscaledTime;

        Vector3 enterPosition = EntityTransform.position;
        if (PassengingVehicleEntity != null)
        {
            enterPosition = PassengingVehicleEntity.Entity.EntityTransform.position;
            await ExitVehicle();
        }

        // Instantiate new mount entity
        LiteNetLibIdentity spawnObj;
        if (prefab != null)
        {
            spawnObj = BaseGameNetworkManager.Singleton.Assets.GetObjectInstance(
                prefab.Identity.HashAssetId, enterPosition,
                Quaternion.Euler(0, EntityTransform.eulerAngles.y, 0));
        }
        else if (addressablePrefab.IsDataValid())
        {
            spawnObj = BaseGameNetworkManager.Singleton.Assets.GetObjectInstance(
                addressablePrefab.HashAssetId, enterPosition,
                Quaternion.Euler(0, EntityTransform.eulerAngles.y, 0));
        }
        else
        {
            return;
        }

        if (spawnObj == null)
        {
            return;
        }

        VehicleEntity vehicle = spawnObj.GetComponent<VehicleEntity>();

        if (addressablePrefab != null)
        {
            Debug.Log("Result_AssetId : " + vehicle.Title);
            Debug.Log("Result_AssetId : " + spawnObj.AssetId);
            Debug.Log("Result_HashAssetId : " + spawnObj.HashAssetId);
        }

        BaseGameNetworkManager.Singleton.Assets.NetworkSpawn(spawnObj, 0, ConnectionId);

        // Seat index for mount entity always 0
        await EnterVehicle(vehicle, 0);
    }

MountItem.cs

    public void UseItem(BaseCharacterEntity characterEntity, int itemIndex, CharacterItem characterItem, int amount)
    {
        if (!characterEntity.CanUseItem() || characterItem.level <= 0)
            return;

        if(AddressableVehicleEntity != null)
        {
            Debug.Log("UseItem_editorAsset : " + AddressableVehicleEntity.editorAsset);
            Debug.Log("UseItem_HashAssetId : " + AddressableVehicleEntity.HashAssetId);
        }
        characterEntity.Mount(VehicleEntity, AddressableVehicleEntity);
    }
insthync commented 1 month ago

Okay, then you have to fix duplicated key by change a asset ID in LiteNetLibIdentity component