This project is read-only.

GameObject Script's dependencies

Sep 16, 2012 at 11:41 AM


I have some GameObject3D objects hiearchy that have Scripts added. I have a car, wheels, steering wheel etc. When I want to move them, i must first move car, then its dependencies and then depencencies of its depencencies etc. I dont know how can I set an order to reused fetched scripts from List to be sure that car script is updated before steering wheel script etc. I cannot use LateUpdate method, because my car objects hiearchy is deeper than 1 dependence.

Any help appreciated.


Sep 17, 2012 at 8:07 AM

Hi Ascaria!!

I still do not implement what you are mention. I recommend seeing Uncharted 2 presentations that talk about your problem (the train example) and also Jason Gregory´s book (also from Naught Dog) called Game Engine Architecture or something like that.

If you want we can develop a solution for that problem together.

However, when you transform the car the child objects should transform accordingly.

Hope it helps!

Sep 17, 2012 at 8:44 PM
Edited Sep 17, 2012 at 8:50 PM


if I set GameObject3D "B" Parent property to another GameObject3D "A", then if I transform "A", then "B" is not transformed. I made some dependent script to do so, but it would be nice if GameObject3D.Parent affects GameObject3D's position and rotation automatically, or have property that can change this behaviour (in case car doors was ripped away).

I have a small idea about that "train example" problem. We can add property public Script Parent to Script class. Then change default empty update and lateupdate methods to contain logic to call Parent script's (if it was set) update&lateupdate first (and add variable that ensure script base.Update is called from override methods, and add comment to inform that base methods must be called at first place). Then in GameLoop class, change Logic Update region so it can check if Script.ScriptList[i] was already updated in current loop, then simply skip it.

If parent is executed first, then no change occurs and child will execute itself normally. but when deepest child is called first, then it first update its parent, and parent first update its parent and so on.

Hope it is a good idea :)


Sep 18, 2012 at 7:47 AM
Ascaria wrote:

if I set GameObject3D "B" Parent property to another GameObject3D "A", then if I transform "A", then "B" is not transformed.

It has to. It works for me.

Not sure if I like the script parenting idea because I want to maintain the interface simple and clean. I suppose I have to read again the articles I pointed to you. Unfortunately (like always) time is not on my side.

However your idea could work for you (and maybe me also). Just implement it in your code and tell me how it works. I want to know from your experience how well it performs.

Thanks! José.