Forum rules - please read before posting.

Constant ID / Visibility Issue

edited March 2020 in Technical Q&A

Okay, I can't seem to work this one out.

Attached to my player character are weapon objects that are enabled via actions (actually animated to be visible, rather than enabled). Some of these weapons also have a dummy object that represent their "unequipped" state - just a mesh with no scripts on it - except for a Constant ID. In this example I will refer to the shotgun.

So, when you equip the shotgun through the inventory, an action list asset will enable the "real" shotgun and hide the dummy shotgun. This works fine. However, when equipping a different weapon, say a pistol, the dummy shotgun does not show, despite that being part of the equipping pistol action list. Then I get these messages in the console, saying it has given the dummy models a new Constant ID, even though it hasn't.

Set new ID for AC.ConstantID to DUMMY_Shotgun: 802676

-> AC debug logger
UnityEngine.Debug:Log(Object, Object)
AC.ACDebug:Log(Object, Object) (at Assets/AdventureCreator/Scripts/Static/ACDebug.cs:16)
AC.ConstantID:SetNewID(Boolean) (at Assets/AdventureCreator/Scripts/Save system/ConstantID.cs:182)
AC.ConstantID:AssignInitialValue(Boolean) (at Assets/AdventureCreator/Scripts/Save system/ConstantID.cs:109)
AC.UnityVersionHandler:AddConstantIDToGameObject(GameObject, Boolean) (at Assets/AdventureCreator/Scripts/Static/UnityVersionHandler.cs:553)
AC.Action:FieldToID(GameObject, Int32, Boolean, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/Action.cs:711)
AC.Action:FieldToID(GameObject, Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/Action.cs:691)
AC.Action:FieldToID(GameObject, Int32) (at Assets/AdventureCreator/Scripts/ActionList/Action.cs:685)
AC.ActionVisible:ShowGUI(List`1) (at Assets/AdventureCreator/Scripts/Actions/ActionVisible.cs:97)
AC.ActionListAssetEditor:OnInspectorGUI() (at Assets/AdventureCreator/Scripts/ActionList/Editor/ActionListAssetEditor.cs:195)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

Here is the action list for equipping a shotgun:

https://imgur.com/a/VzJtJTQ

Here is where the other dummy weapons should be made visible, but they are not (they are in the inventory).

I appreciate it may be hard to follow if you don't know what's going on though, I will elaborate where I can.

Comments

  • Actually, I think I can just avoid this by disabling/enabling the dummy objects' Mesh Renderers as animations.
    Only problem is, I am going to have to put an animator on each one, as there is a bug in Unity that prevents you from adding them to the same animations as the objects that are already animated (the real weapons in this case).

  • If you click on the Console message you're reporting, it'll ping the object it's referring to. You shouldn't be getting this message at runtime.

    Typically it's better to rely on animation entirely for object swapping / visibility changes on Player children, but I'm not clear on the way you've set things up. Are all weapons (dummy and real) children of the Player? You could just use a single Animator for everything in that case.

    I'm not sure what Unity bug you're referring to, either.

  • It's okay, I got it working just by using animations in the end.

    The Unity thing could just be a limitation of how it works rather than a bug, but here is what was happening to me:

    Say you have an object that is animated, parented to a character's hand. Later on, you decide you want to add another object to this same animation (using the same animator), but this new object is a child of another bone, such as the spine. Unity's animation window will not allow you to add the new object to the animation, even if you have both objects selected. It will add it, but will overwrite the old mesh somehow, and won't allow them to animate at the same time - it's very odd and a bit hard to explain.

    Anyway, there is an asset called UMotion that allows you to edit existing animations (even imported fbx files that Unity wouldn't allow as it sees them as read-only) and even add new objects to the same animation. Highly recommended.

  • Actually I don't think UMotion does animate properties other than rotate, scale & position. It is great, but I don't want to mislead anybody.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.