Author Topic: Check players in trigger  (Read 1778 times)

krvc

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 16
    • View Profile
Check players in trigger
« on: October 11, 2016, 01:20:19 AM »
Hi. I have shop in game, it open when Player whith Tag "Player" enter to zone.
 if (col.gameObject.CompareTag("Player"))
Shop open to all players not for one. What i need add to fix problem? Shop not have TNOobject. (players have, TNManager.Instantiate(2, "SoulCreate", prefabName, false, pos, rot);)

cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 149
  • Posts: 285
  • TNet Alchemist
    • View Profile
Re: Check players in trigger
« Reply #1 on: October 11, 2016, 01:52:00 AM »
Opening your shop is a network call? GUI elements like a shop GUI don't have to be driven by the network. Make opening the shop GUI driven by the client and purchasing or selling items network calls.

An immediate fix for your problem, though, could be instead to place your OnTriggerEnter logic in your player script and check if it enters a Shop tag. Then you can use tno.isMine so that it's only ran on the local client.

krvc

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: Check players in trigger
« Reply #2 on: October 11, 2016, 02:14:37 AM »
its UI element.
player go to zone, interface shop set active. for all.... need for me.

void OnTriggerEnter(Collider col)


        if (col.gameObject.CompareTag("Player"))

        {
            ShopWallBase.SetActive(true);

        }
« Last Edit: October 11, 2016, 02:20:24 AM by krvc »

cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 149
  • Posts: 285
  • TNet Alchemist
    • View Profile
Re: Check players in trigger
« Reply #3 on: October 11, 2016, 02:34:50 AM »
You should rethink your design.
For an immediate fix (but not the best):
  1. void OnTriggerEnter(Collider col)
  2. {
  3.         if (col.gameObject.CompareTag("Player"))
  4.         {
  5.                 if (!col.gameObject.GetComponentInChildren<TNObject>().isMine)
  6.                         return;
  7.                 ShopWallBase.SetActive(true);
  8.         }
  9. }
  10.  

krvc

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: Check players in trigger
« Reply #4 on: October 11, 2016, 03:53:06 AM »
Really thks!
 But i dont know what wrong whith my design. I orient on Warcraft3 - http://nightbeauty.ru/shop.jpg
Shop interface not active but you can see it. If you go to zone - shop switch to active.