playMaker

Author Topic: Set visible to a prefab  (Read 1940 times)

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Set visible to a prefab
« on: February 27, 2014, 03:26:58 PM »
Hi!
I have a dynamite to pickup. And when I pick it up, I set it to invisible.
And when I press the Z-key, I use the action "Create GameObject" to place the dynamite prefab. After 2 sec, the dynamite will explode and I set it to invisible, since I can't destroy a prefab. But it will not be invisible. Doesn't this work, to set visible to a prefab? When I stop the game, the prefab mesh renderer is off.
Do I do something wrong?
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Set visible to a prefab
« Reply #1 on: February 27, 2014, 03:44:03 PM »
Are you trying to change the value on the prefab or the copy you created in the scene?
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Set visible to a prefab
« Reply #2 on: February 27, 2014, 03:56:19 PM »
I'm going to change the prefab to invisible.
I place the prefab in the scene. And when I pick it up, I store it in and Int variable.
So I can press the z-key to create a prefab to place it again in the scene.
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Set visible to a prefab
« Reply #3 on: February 27, 2014, 04:34:27 PM »
When you create it in the scene, do you recycle the same object for throwing more grenades?

Once you spawn it, you're creating an instance of the prefab into the scene, so you need to interact with that specific object instead of the prefab for any kind of visibility changes.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Set visible to a prefab
« Reply #4 on: February 27, 2014, 04:49:17 PM »
I think I do. Because all other things is working. It's only the visible thing that is not working. I can pick up a dynamite and place it again and it will explode, but the dynamite doesn't disappear.

Can you explain me a little bit more how to do it? It's a bit challenging for me to make prefabs disappear etc.
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no