Using the same scripts for different spawned gameobjects

Discussion and help for Easy Save 3
Post Reply
RookieN
Posts: 2
Joined: Fri Feb 04, 2022 7:10 pm

Using the same scripts for different spawned gameobjects

Post by RookieN »

So im trying to integrate this with RTS Engine, In this game there are "units" that are spawned at runtime from "buildings" and 1 unit that you spawn with already in the scene. These Units have scripts like UnitMovement, UnitHealth, Unit etc i have added the prefab and references as the guide tells and got autosaving/loading on. It saves the already placed "villager unit" there perfectly and it also saves the instanciated units BUT only in the session. When i press play again to go out from the playview and in again the unit placed works, and the other units that spawned in runtime are there, but 2 of the scripts couldnt be referenced "unitmovement and Unitcomponent".

What i think is that the save tries to put the scripts on only 1 of the units so for me the already spawned one because it doesnt know the other spawned versions? Or something that the game think the units IsDead and therefor not activating it? I really need this to work since all units use these scripts so any pointers on how i can go about this? I am VERY new to this with coding and such so try to make it as clear as possible :D

Here are all 4 Images i took, i could only add 3 on the post. https://imgur.com/a/vi1w2qo
Attachments
help3.png
help3.png (202.11 KiB) Viewed 639 times
help2.png
help2.png (572.4 KiB) Viewed 639 times
help1.png
help1.png (372.47 KiB) Viewed 639 times
User avatar
Joel
Moodkie Staff
Posts: 4852
Joined: Wed Nov 07, 2012 10:32 pm

Re: Using the same scripts for different spawned gameobjects

Post by Joel »

Hi there,

As your issue and error messages are specific related to RTS Engine, which we do not have any experience with and do not officially support, I’m afraid I wouldn’t be able to assist with this.

It may be worth contacting the developers to ask which fields of their scripts would need to be saved at runtime in order to function correctly. This is not a question we could answer without purchasing RTS Engine and learning how their scripts work in their entirety.

If you’re able to replicate your issue in a project which isn’t coupled to assets we don’t officially support and private message it to me, I’m happy to look into it further.
If you’re not able to decouple the issue from RTS Engine I can take a look if you send me a new project which a very minimal scene involving RTS Engine, but I can’t guarantee I’ll be able to find a solution, especially as there’s no guarantee they’ve made their classes serialisable at runtime.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
RookieN
Posts: 2
Joined: Fri Feb 04, 2022 7:10 pm

Re: Using the same scripts for different spawned gameobjects

Post by RookieN »

Hmm dont know how i can do it without since its specifcally this scripts and asset im having trouble with, Is it possible to send you just these 2 scripts? just so you can have a look and see if it can be serialized or such since im trying to understand and learn it all so i might have missed something? :P since it saves at runtime perfectly its just it wont save when exit playmode and entering again, or do they all need a unique ID somehow?
User avatar
Joel
Moodkie Staff
Posts: 4852
Joined: Wed Nov 07, 2012 10:32 pm

Re: Using the same scripts for different spawned gameobjects

Post by Joel »

Hi there,

You can send me a simple project containing the bare minimum RTS Engine scripts in your scene to replicate it, but I can’t guarantee I will be able to provide a solution as it depends on how simple their scripts are to whether I can understand it.

With serialisers they will generally save and load variables just fine. However, when scripts require something else to be done with that information after saving and loading the variable, that is when you will encounter issues.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply