Forum rules - please read before posting.

Card Game Feature

13

Comments

  • edited February 2021

    It is in the "Engine" Actions category.

    What is your AC version?

    Alternatively, you can use the Player: Constrain Action to prevent movement in all four directions.

  • edited February 2021

    What's the issue, then? Is it not appearing in ActionLists?

  • edited February 2021

    I think he just wants things to happen and confused.
    It looks to me you have set up everything correct what Chris said. But now you want things to work.

    But what exactly do you want?
    Please explain in details it would save time. Don't worry about your super secret million $ idea :)

    What you do after with cards is entirely up to you after you added hotspots and colliders. Now you can tell the engine and AC what to do through interaction lists you make and attach to the Hotspots of your prefabed cards.

  • i did everything

  • edited February 2021

    What did you put in your actionlists then?

    And please explain step by step what you want.

    E.g.
    1. Approach an NPC.
    2. Cards show up.
    3. Hover mouse over cards and select one.
    4. Give the card to the NPC.
    etc.

  • edited February 2021

    Check what Chris said at 12:46 today in the previous page.

    Engine: Manage systems Action to lock the Movement system

    You do it in your interaction actionlist (or cutscene ) that you create and attach to the Hotspot.
    Instead you went looking for it in the Managers.

  • I did everything you said Chris. But for the cards to work do I need any custom script?

  • edited February 2021

    Since you're dealing with dynamic elements, you may need to make use of a custom script to find tune behaviour depending on exactly how you want them to work, but you shouldn't need anything further simply to make them interactive.

    What is the state of their interactivity now? Have you assigned ActionList asset files for the Hotspot Interactions? Please share as much detail / screenshots as you can, so that I can be clear on exactly what your situation is.

  • I made a video so you can watch that and that is just how its made in unity without AdventureCreatorPack.

    But this is still how we want it in Unity with AdventureCreator pack.

  • edited February 2021

    There's no need to re-invent it. If you already have it working without AC, you don't need to rely on AC to make something similar - you can still use the same scripts and AC at the same time.

    You just need to incorporate those scripts onto your card prefabs instead of AC's Hotspot component.

    Your video doesn't show what scripts are involved, or if there's e.g. a Manager script/object that needs to be included separately, but that too can be added in with the spawning script if necessary.

    If you need me to clarify, you will need to share more details on how the above is achieved.

  • I got a link so you can see the scripts. You can click on the link and download de scripts.
    https://we.tl/t-WDfhnlMYcA

  • edited February 2021

    You can incorporate the code from CardSpawner and your GameMan script, so that the cards get spawned and kept track of, for later removal.

    For example, this hybrid below. Make sure your Card prefabs have the Card script attached, and have the Card script refer to CardSpawner instead of GameMan.

    using UnityEngine;
    using System.Collections.Generic;
    using AC;
    
    public class CardSpawner : MonoBehaviour
    {
    
        public _Camera firstPersonCamera;
        public Transform leftTransform;
        public Transform middleTransform;
        public Transform rightTransform;
        private List<GameObject> cardsList = new List<GameObject> ();
    
        private void OnEnable () { EventManager.OnSwitchCamera += SwitchCamera; Debug.Log ("CardSpawner - Registered event"); }
        private void OnDisable () { EventManager.OnSwitchCamera -= SwitchCamera; Debug.Log ("CardSpawner - Unregistered event"); }
    
    
        private void SwitchCamera (_Camera old, _Camera newCamera, float transitionTime)
        {
            if (newCamera == firstPersonCamera)
            {
                SpawnCards ();
            }
        }
    
    
        private void SpawnCards ()
        {
            InvItem[] invItems = KickStarter.runtimeInventory.PlayerInvCollection.InvItems.ToArray ();
    
            if (invItems.Length > 0)
            {
                // Spawn first at middle
                SpawnCard (invItems[0], middleTransform);
    
                if (invItems.Length > 1)
                {
                    // Spawn second on left
                    SpawnCard (invItems[1], leftTransform);
    
                    if (invItems.Length > 2)
                    {
                        // Spawn third on right
                        SpawnCard (invItems[2], rightTransform);
                    }
                }
            }
    
        }
    
    
        private void SpawnCard (InvItem invItem, Transform appearTransform)
        {
            if (invItem.linkedPrefab == null)
            {
                Debug.LogWarning ("CardSpawner - Cannot spawn item " + invItem.label + " in the scene, as it has no linked prefab.");
                return;
            }
    
            if (appearTransform == null)
            {
                Debug.LogWarning ("CardSpawner - Cannot spawn item " + invItem.label + " in the scene, as no Transform was assigned.");
                return;
            }
    
            GameObject cardInstance = Instantiate (invItem.linkedPrefab);
            cardInstance.transform.SetParent (appearTransform);
            cardInstance.transform.position = appearTransform.position;
            cardInstance.transform.rotation = appearTransform.rotation;
    
            cardsList.Add (cardInstance);
        }
    
    
        public void RemoveCards (Card cardScript)
        {
            //Remove the selected card
            cardsList.Remove (cardScript.gameObject);
    
            //Destroy the cards that are still in the list
            for (int i = 0; i < cardsList.Count; i++)
            {
                Destroy (cardsList[i]);
            }
        }
    
    }
    

    As before, if you run into trouble, please elaborate as best you can.

  • The cards don't spawn in anymore. I did everything you said.
    I gave the cardprefabs the card script, I copied this script and replaced it with the old cardspawner script and I did copy the cardmanager script and put it in the cardspawner. Also I refered to the cardspawner script with the card script.
    But do I need do delete the hotspot script and the highlight script from the card prefab?

  • edited February 2021

    When you last had this issue, it was because you didn't have the inventory items in your current inventory. Might this be the case again?

    The script parents all spawned cards to the Transform fields in your Inspector - check the Hierarchy to see if they're there.

    This alternative script re-adds the Debug.Log statements that shows how far things go in the Console - what does it show?

    https://pasteall.org/iErO

    But do I need do delete the hotspot script and the highlight script from the card prefab?

    You can keep them if you want the name / highlight effect to appear - just leave the Interaction ActionList fields blank so that the click behaviour is still handled by your script.

  • In the hierarchy

  • I made a video of all the details.

  • Your video did not capture the script when you alt-tabbed to it. Which script are you using now? The one in my last link?

    The video also does not show where and how you've configured this script's Inspector.

    What does the Console say? If you're using the latest script, it should report a Warning if something goes wrong.

    You only show 3 inventory items, but you have 5 items defined. Are those first two also present in your runtime inventory?

    The script works by taking the first three items in your inventory - not the first three that have linked prefabs. The script can be modified to work like that, but it depends on exactly what it is you're looking to do. First though, make sure the only items in your inventory are those with linked prefabs.

    1. i am using your script the latest one and the card script.
    2. I fixed that 3 off them spawn er are no errors anymore or warnings.
    3. i fixed that you now only have 3 inventory items.
    4. Now i need to make that the inventory items stay on there place when i hover over them with my mouse and when you click on one of the items the other items go away and that the one i clicked on is going to the middle.
    5. https://cdn.discordapp.com/attachments/503593005266108427/813704532835696670/unknown.png
    6. https://cdn.discordapp.com/attachments/503593005266108427/813704664071536640/unknown.png
    7. https://cdn.discordapp.com/attachments/503593005266108427/813704850901696582/unknown.png
    8. https://cdn.discordapp.com/attachments/503593005266108427/813705016745132042/unknown.png
    9. Here this is the card script and that goes on every cards and i think that this is the reason why the cards go somewhere else instead of staying in front of the camera.
  • The cards move because of your own Card script's OnMouseOver function. If you don't want the card to move when hovering over it, comment it out.

    If you instead want cards to move to another Transform - instead of a fixed position - then the CardSpawner code can be amended to provide that.

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.