objects & script links

(Cosimo_0) #1

Question: say, I want to generate an animation with a script via script links. I want to instantiate a class and have that object perform a method each subsequent frame. I have the class definitions and the code all in the same text. How do I keep from instantiating a new object of that class with every frame and will the instantiated object remain available for subsequent frames?

(did I make myself clear? please let me know if not, to explain more carefully)


(chipmasque) #2

You could perhaps test for the presence of your object instance and code a bypass of the instantiation code if it already exists. Iterating through scene objects every frame might be (relatively) slow depending on scene size (in terms of object count) but it’s a means of finding an existing instance.

I can see no reason why the instance shouldn’t persist unless the code unlinks it for some reason.

A faster and probably more efficient method would be to do all the instantiation in an unlinked script, and have only the frame-by-frame methods scriptlinked.


(Cosimo_0) #3

see, I don’t know how to do that(yet?)