How to use SetSkinName in TGEA
by ChenJian · in Torque Game Engine Advanced · 07/17/2008 (8:38 pm) · 5 replies
I write an StaticShapeData and want its skin changed at sometime. I know in TGE, it's an easy work to use SetSkinName method. But in TGEA, I get no luck.
My object name is mysensor1, and has 3 skins : base.sensor.png, warm1.sensor.png and warm2.sensor.png.
When I use Console command mysensor1.setSkinName("warm1");
The Object's skin changed to TGEA's "NO MATERIAL" skin, and I get the echo : Mapping string : warm1 to index: 13;
So anybody can kindly help me out. Any suggestion will be much appreciated.
My object name is mysensor1, and has 3 skins : base.sensor.png, warm1.sensor.png and warm2.sensor.png.
When I use Console command mysensor1.setSkinName("warm1");
The Object's skin changed to TGEA's "NO MATERIAL" skin, and I get the echo : Mapping string : warm1 to index: 13;
So anybody can kindly help me out. Any suggestion will be much appreciated.
#2
EDIT: Okay found it here: http://www.garagegames.com/mg/forums/result.thread.php?qt=74084
07/17/2008 (11:07 pm)
There was a post on this when 1.7 was in beta or when it first came out and someone posted a fix in the thread. I did a quick search just now and couldn't find the thread, but it's in here someplace and probably still works on 1.7.1.EDIT: Okay found it here: http://www.garagegames.com/mg/forums/result.thread.php?qt=74084
#3
07/19/2008 (8:05 am)
Thanks a lot, Smith. I am now using 1.0.3. In fact, I have never thought of editing the engine code instead of just using script code. So, I would like to have a try. And before that, I found an clumsy way to solve this problem. Since I can not change the skin, I then delete the object, and create another object with the next skin at the same place, 1 second later, I delete this object again and create another object. This does give me the same effect, but I think this may take more system resource. :)
#4
A) Be sure to create the new object before deleting the old one. I suggest making it a clone of the first object, then setting its skin the way you mentioned. (Which only works once, but hey, it's a new object so once is all you need
B) I suggest the new object to be a clone of the first to make sure it has all the necessary parameters
C) Making objects/deleting old ones CAN be noticeable if you are not careful. Make sure to keep the timing tight, like 1-10ms between creation/deletion. Also note that if the original object is animated or moving, you will be far more likely to notice the "switch", so try to delete/create while the object is stationary.
07/21/2008 (11:15 am)
Not entirely sure about system resources, but I can tell you this:A) Be sure to create the new object before deleting the old one. I suggest making it a clone of the first object, then setting its skin the way you mentioned. (Which only works once, but hey, it's a new object so once is all you need
B) I suggest the new object to be a clone of the first to make sure it has all the necessary parameters
C) Making objects/deleting old ones CAN be noticeable if you are not careful. Make sure to keep the timing tight, like 1-10ms between creation/deletion. Also note that if the original object is animated or moving, you will be far more likely to notice the "switch", so try to delete/create while the object is stationary.
#5
07/21/2008 (5:40 pm)
Thanks very much, Nicolai. Your suggestions are very useful.
Torque Owner ChenJian
I really really really gonna be crazy :OOOOO