playMaker

Author Topic: Prefab objects (coins) not "remembering" their initial position[SOLVED]  (Read 1686 times)

Neikke

  • Full Member
  • ***
  • Posts: 134
I have a platform with a few coins set up as prefab and which I'm spawning constantly every other second. On Player - I have a magnet which drags coins from their original position/s towards Player when Player's Magnet is active. And when they collide with Player - I deactivate coin.

Now I run into some weird situation - when the next platform is spawned - coins are being reActivated in the location where they've been deactivated on collide with Player rather than in their original locations as they should. I'm experiencing this weird thing in almost all of my prefabs - when anything is altered during runtime - on the next spawn it "remembers" the way it was tweaked rather than spawning from original prefab!

Why can't it just reference to original prefab and start everything in accordance with the original? Is there a way to kind of reset prefab on every spawn? Thanks in advance!
« Last Edit: October 24, 2017, 03:33:59 AM by jeanfabre »

Ofonna

  • Full Member
  • ***
  • Posts: 230
Re: Prefab objects (coins) not "remembering" their initial position
« Reply #1 on: October 23, 2017, 01:48:06 PM »
hmmm i'm trying to understand the issue.

from what i understand you're deactivating and reactivating coins when you need them, if that's the case you need to manually reset the coins back to their positions with some logic because deactivated objects are still present in your scene and can still be moved or altered before activation. which is why when you deactivated the coins they were still sitting where you left them.


djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Prefab objects (coins) not "remembering" their initial position
« Reply #2 on: October 23, 2017, 06:39:06 PM »
Hi,
if the location is always the same you can use a "set position" in the 1st state.

So when it is activated it will be placed to that position.

Neikke

  • Full Member
  • ***
  • Posts: 134
Re: Prefab objects (coins) not "remembering" their initial position
« Reply #3 on: October 23, 2017, 07:15:29 PM »
Hi Dino,

like that? (attached) Or should I store its Vector as local variable? I tired the way it's on the screenshot and it's not working. When the next platform spawns Coins appear exactly in places where they collided with Player..
« Last Edit: October 23, 2017, 07:19:23 PM by Neikke »

Neikke

  • Full Member
  • ***
  • Posts: 134
Re: Prefab objects (coins) not "remembering" their initial position
« Reply #4 on: October 23, 2017, 07:30:03 PM »
I also tried this (attached) still after a few spawns, original coin positions get screwed..

Neikke

  • Full Member
  • ***
  • Posts: 134
Re: Prefab objects (coins) not "remembering" their initial position
« Reply #5 on: October 23, 2017, 08:02:29 PM »
It worked!

1. I added Get Position and stored its position as local variable LocalCoinPosition
2. Added Set Position with LocalCoinPosition as 'Vector' variable after Deactivating Coin - so after deactivation it just (invisibly) returned to its original place!

Thanks for the heads up Dino!
« Last Edit: October 23, 2017, 08:07:14 PM by Neikke »