Move To Shop Keeper Before Setting Active Shop

Hi, me again.

I tried to implement a similar system that we used to move to the target NPC before initializing dialogue to move towards the shop keeper before opening the shop. I’m close, but I’m missing something.

Shop.cs

public bool HandleRaycast(PlayerController callingController)
        {
            if (Input.GetMouseButtonDown(0))
            {
                if (Vector3.Distance(callingController.transform.position, this.transform.position) > 3)
                {
                    callingController.GetComponent<Mover>().StartMoveAction(this.transform.position, 1);
                }
                else
                {
                    callingController.GetComponent<Shopper>().SetActiveShop(this);
                }
            }
            return true;
        }

Edit: I spotted an error and have managed to get the player to move to the position without opening the UI, but now it requires a second click once you’ve arrived to open the shop UI.

I also had to disable the shop keeper’s Fighter and Combat Target scripts to stop them from killing each other. I’d like it to be possible that should the town guards become hostile, the shop keeper does too, but I can’t for the life of me figure out why she’s hostile when everyone else is docile. She’s a prefab variant of the King, and he’s not beating me to death with his wares like she is. :stuck_out_tongue:

Any tips?

Thanks,
Mark.

Hi,

Not sure if its the best solution, Brian will probably come with something better when he sees your post.
I believe i did somethig similar in shops to how i did it with the dialogue;

basically as soon as the method was called, it would store the conversant, or shop in this case,
check if its in range, if not, move to and then call the method again with the saved conversant/shop from first time from update() automatically

Im not sure about the hostility, i believe it was something in the order of components maybe?
like a method, the components on a gameobject are handled top to bottom, so your shop component
had to be above the fighter, i seem to recall something like this from the course anyways.
Well maybe what i said helped you, maybe not, if not; just wait for Brian!

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms