playMaker

Author Topic: [SOLVED] CHECK FOR DUPLICATE  (Read 5025 times)

wallaceb68

  • Junior Playmaker
  • **
  • Posts: 87
[SOLVED] CHECK FOR DUPLICATE
« on: February 27, 2014, 10:20:35 AM »
I am trying to figure a way to check if a game object in my hierarchy is duplicated. and if so delete one of them.
« Last Edit: February 28, 2014, 09:13:32 AM by Lane »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: CHECK FOR DUPLICATE
« Reply #1 on: February 27, 2014, 10:23:07 AM »
If it's stored in a variable you can use CompareGameObject. Otherwise you can use FindGameObject to scan the scene for it.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

wallaceb68

  • Junior Playmaker
  • **
  • Posts: 87
Re: CHECK FOR DUPLICATE
« Reply #2 on: February 27, 2014, 10:42:51 AM »
ok but how do i only delete one of them?
« Last Edit: February 27, 2014, 10:49:56 AM by wallaceb68 »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: CHECK FOR DUPLICATE
« Reply #3 on: February 27, 2014, 10:51:53 AM »
Once you find it and put it into a variable use DestroyObject.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

wallaceb68

  • Junior Playmaker
  • **
  • Posts: 87
Re: CHECK FOR DUPLICATE
« Reply #4 on: February 27, 2014, 11:29:17 AM »
will that not destroy both of them?

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: CHECK FOR DUPLICATE
« Reply #5 on: February 27, 2014, 12:01:00 PM »
How? You're only identifying one object to destroy. Unless it's part of a child hierarchy then it cannot.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

wallaceb68

  • Junior Playmaker
  • **
  • Posts: 87
Re: CHECK FOR DUPLICATE
« Reply #6 on: February 27, 2014, 12:08:43 PM »
OK here is what i got,
in an empty game object-
i have an FSM set up like this:
STATE 1:
action 1-    find game object( Object name: player, with tag: untagged, store(in local variable) variable-duplicated G.O.)
action 2: next frame event
STATE 2:
action 1- Game Object Compare( game obect: variable- duplicated G.O., compare to: player, equal event: next, not equal event: reset)
STATE 3:
action 1- Destroy Object( Game Object: variable- duplicated G.O.)


this works great when before the start of the game i added a 2nd player to scene, and it removed one of them, but when i removed the 2nd one ran the game, it deleted the 1st player.

what am i doing wrong?

 thank you so much lane for being understanding and trying to work me thru this.
« Last Edit: February 27, 2014, 12:10:17 PM by wallaceb68 »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: CHECK FOR DUPLICATE
« Reply #7 on: February 27, 2014, 01:40:33 PM »
this works great when before the start of the game i added a 2nd player to scene, and it removed one of them, but when i removed the 2nd one ran the game, it deleted the 1st player.

Which one do you want to delete?
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

wallaceb68

  • Junior Playmaker
  • **
  • Posts: 87
Re: CHECK FOR DUPLICATE
« Reply #8 on: February 27, 2014, 01:48:52 PM »
the one left behind i guess, but either one would work, i could just retransform the one that is left if it is in the wrong spot. thanks again lane for your help.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: CHECK FOR DUPLICATE
« Reply #9 on: February 27, 2014, 02:01:24 PM »
Yep, so pick which one and stick with it to keep consistent in your design.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

wallaceb68

  • Junior Playmaker
  • **
  • Posts: 87
Re: CHECK FOR DUPLICATE
« Reply #10 on: February 27, 2014, 02:08:21 PM »
lane i found this while doing a search-


public void Awake()
    {
        DontDestroyOnLoad(this);
 
        if (FindObjectsOfType(GetType()).Length > 1)
        {
            Destroy(gameObject);
        }
    }
 how can i turn this into a playmaker action?

wallaceb68

  • Junior Playmaker
  • **
  • Posts: 87
Re: CHECK FOR DUPLICATE
« Reply #11 on: February 27, 2014, 02:10:17 PM »
Yep, so pick which one and stick with it to keep consistent in your design.

lol, i'm still as lost as last years Easter egg. i am getting the "what to do" just not the "how to do it"

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: CHECK FOR DUPLICATE
« Reply #12 on: February 27, 2014, 02:18:13 PM »
This is kind of what I was thinking it could work like.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

wallaceb68

  • Junior Playmaker
  • **
  • Posts: 87
Re: CHECK FOR DUPLICATE
« Reply #13 on: February 27, 2014, 03:28:06 PM »
OK thanks so much, thats what i needed, just got one question.
the variable "dogkeptthrulevels" where do you get the info for that variable? i take it that it is a G.O. global variable, right. did you just preset it with the dog that has the donot distroy attached to it?

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: CHECK FOR DUPLICATE
« Reply #14 on: February 27, 2014, 03:41:25 PM »
Yes, its the one that you put the do not destroy on.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D