playMaker

Author Topic: Clones variable does not reset between play sessions?  (Read 1057 times)

LNMRae

  • Playmaker Newbie
  • *
  • Posts: 2
Clones variable does not reset between play sessions?
« on: January 08, 2019, 08:57:49 AM »
So this is a weird one that I have no idea what could possibly be going on.

I am working on a turn based game. Right now, I have the characters spawning using Create Game Object, resulting in clones of prefabs that have their own FSMs with variables on them for their stats.

I select the enemy as a target for an attack using Set Game Object, creating a global variable. The attack FSM uses Get FSM Float to get the enemy's HP, do some math, and then set the new number as the new HP amount.

I've found that while in play mode, the enemy does NOT take damage. However, if I stop the play mode, and then start the play mode again, the HP variable now has the damage on it when the clone is respawned.

I can't for the life of me figure out why a cloned object would retain a variable change between play sessions on a local HP variable. Especially when it fails to take damage during the previous play session.

The prefab it's cloning still has its default HP variable, but the clone has damage. The only way the clone will start to use this base variable again is if I deactivate the FSM on the prefab and re-enable it.

Any ideas what could be going on here? My understanding is that stopping the scene and restarting it should reset everything, so I don't understand why my clones have damage from a previous session.

ch1ky3n

  • Full Member
  • ***
  • Posts: 208
Re: Clones variable does not reset between play sessions?
« Reply #1 on: January 08, 2019, 09:15:24 AM »
Did you by any chance use playerprefs in your fsm ?
Have you take a look at the global variables ?
Everything will be easier if you post an SS.
I’m curious on what global variables that you’ve created ?
Or
You could debug log, toggle breakpoints on the state and track the number changes and which variables the clones retireved from
« Last Edit: January 08, 2019, 09:18:41 AM by ch1ky3n »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Clones variable does not reset between play sessions?
« Reply #2 on: January 22, 2019, 03:29:02 AM »
Hi,

 Also, it could be that you are reference the prefab asset and not the prefab instances.

Bye,

 Jean