Forum rules - please read before posting.

Set parent make lose the remember transformation script?

edited August 2014 in Technical Q&A
Big problem with save/load games.
I have 2 game object (panel A and panel B) that are children of another game object (a door). Panel A move to a position and after that become parented to panel B. When they are parented they move together to another position.
They have the remember transformation script, tried with the "Save change in Parent" checked and unchecked.
When I save game when they move to another position and then I exit and reload that game, the 2 object are in their original position... X(
Am I making something wrong? Other game object not parented works perfect in save/load operations...
Tx

PS: I used the object - set parent - action to do that

Comments

  • Is it just that the positions are wrong, or is the parenting wrong as well?

    Don't forget that the parent object (the door, if I've followed you) also needs a ConstantID number.
  • Yes, also the door have the Remember transformation and the ConstantID.

    Seems that only the positions are wrong. When I reload the saved game made when they change their positions from A to B, they're still in the A position...
  • edited August 2014
    Made other test. Now only the father (the door) have the remember script attached.

    If I save when game objects are in B position and then I reload it, the game object (in the above ex. the panel A and B and all the other children) are in the right position, the B position.

    But...

    If I exit the game (or stop the preview in unity) and then re-run the game and load it, the game objects are back in the A position! O_O!

    In the father game object (the door) I have other children not been parented each other and they work fine, they remain in the B position also after re-run the game.

    So I think it's a set parent problem related...
  • Again: is the parenting wrong?  You haven't told me whether or not the hierarchy is correct after loading back - that'll affect the positioning.

    Also, does the object have a different parent before being parented to the door?  If it does, this'll need a ConstantID as well.  If not, attach it to an Empty - seems there's a bug with remembering parenting changes if it doesn't have one to begin with.
  • After loading, the parenting become wrong. They don't remember with who was parented...
    The object is parented with only the door.

    Before setting the parent, game obj are:
    Door (father with remember transform script)
    -Panel A (parent Door) (tried to attach the rememb transf script without success)
    -Panel B (parent Door)
    -Panel C (parent Door)

    After the set parent:
    Door 
    -Panel A (parent Door)
    --Panel B (parent Panel A)
    -Panel C (parent Door)

    Panel A move to another position (so also Panel B go). From Alpha to Omega.
    Panel C move to another position. From Alpha to Gamma.

    SAVE

    Exit game

    LOAD

    The situation is like in the beginning, without any "subparented" game obj.
    And Panel C is in the right position moved. (Gamma)
    Panel A and B are in the wrong position, before moved. (both Alpha)

    I think that parenting aren't remembered... maybe need a Remember Parent script?
  • No.  The RememberTransform should handle that.  What do you mean by "without success" when adding the script to Panel A?

    Try just adding RememberTransform scripts to all four objects, and check "Save parent" on Panel B.  Make sure there are no other Rembember or Constant ID scripts on them: there's a bug discovered (fixed in 1.38) where having multiple save scripts will cause AC to get confused.
  • Ok Chris, thanx to your suggestions, I found the issue: one game object has 2 constant ID, one for the remember transform and one for the remember visibility. When I removed the remember visibility all worked fine. 

    I tried to assign the same Constant ID by setting it manual but it change to auto when I run the game...

    If I wanna use both (transform and visibility) I have to wait for the 1.38? If it's so simple, I leave it as it is now without loss other time to fix... 
  • I'm afraid so.  It's annoying it took me so long to realise, but 1.38 will be worth the wait, trust me ;)
  • No worry man, I'm not asking the new 1.38 now!  :))
    I just asked if 1.38 will fix this issue, so I can wait, no problem!

    <):)
  • I also have this problem with animation states remaining (2D).

    My approach to a door opening has been to play a custom animation which has all the frames from closed to open.

    I encounter the issue upon loading a saved game to a point before-open coming back from a time after-open. The door doesn't go back to closed but all the other logic does so that's all working as expected: just the door LOOKS open.

    I tried adding 'constant ID' to the door object but it doesn't do anything. Is there not a 'remember animation state' script or equivalent?
  • Have you already upgraded to 1.38a? This solved my issue. I removed all the remember transformation from child and put the remember transformation to the father. When I save after transformation and reload it, all are in the right position.
  • Yeah I'm on 1.38b actually

    The animation isn't a transform as its 2D. At least I don't think it counts as it as its a sprite anim. I'll gladly stand corrected but my animated door isn't going back where it should :/
  • A ConstantID won't remember animation states.

    In order to have an animation load correctly when restoring a save game / re-entering a scene, you have to set it manually within your "On Load" Cutscene, as set in the Scene Manager.

    For example, if you have a door that you want to save open/closed, set this state in a local boolean Variable, within the Variables Manager.  Then, when the game loads, you can use the Variable: Check Action on this boolean, and play either the "shut" or "opened" animation accordingly (even if it's a one-frame animation).

    This is how the 3D demo game plays the correct animation on the barrel - break open the Basement scene's OnLoad Cutscene for a complete example.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.