How to update TSStatic position?
by Justin Tolchin · in Torque Game Engine · 04/06/2005 (6:03 pm) · 4 replies
Hi all,
Well this has me feeling stupid. :-( I created a new TSStatic object via a script method:
It shows up fine and in the right place when I first create it, but when I try to update the position (via a 'setPosition' ConsoleMethod I added to the SceneObject class) it doesn't move. I also tried adding the setPosition method to the TSStatic class and having it call setTransform but it still doesn't move.
When I query the object for its position it gives me the right answer, it just doesn't render in the correct place. I'm guessing it's not propagating the position down to the client for some reason, but I don't know how to make this work. How do you normally (re)position a TSStatic object?
Thanks!
Well this has me feeling stupid. :-( I created a new TSStatic object via a script method:
ConsoleFunction( addTSStatic, S32, 5, 5, "(string shapeName, string position, string rotation, string scale)")
{
TSStatic* pStatic = new TSStatic();
pStatic->setField("shapeName", argv[1]);
pStatic->setField("position", argv[2]);
pStatic->setField("rotation", argv[3]);
pStatic->setField("scale", argv[4]);
// register the object
if (!pStatic->registerObject())
{
Con::errorf("addTSStatic: could not register TSStatic");
delete pStatic;
return 0;
}
return pStatic->getId();
}It shows up fine and in the right place when I first create it, but when I try to update the position (via a 'setPosition' ConsoleMethod I added to the SceneObject class) it doesn't move. I also tried adding the setPosition method to the TSStatic class and having it call setTransform but it still doesn't move.
When I query the object for its position it gives me the right answer, it just doesn't render in the correct place. I'm guessing it's not propagating the position down to the client for some reason, but I don't know how to make this work. How do you normally (re)position a TSStatic object?
Thanks!
#2
I was getting myself confused about the right way to do this. Initially I had wanted something that only existed client-side, so I was using the "client-side only" TSStatic resource here:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6504
That's where the ConsoleFunction above came from. But then I realized I needed the object to be server-side as well, so I just modified the ConsoleFunction to make a regular TSStatic. But I'll do it the normal way from now on. :-)
I didn't know about the Item class, so I'll try using that instead. But now I'm wondering: TSStatic objects can be moved around in the Mission Editor, so how does it do it?
Also, is there a good resource somewhere that explains the differences (and relationships) between:
ShapeBase
StaticShape
ShowTSShape
SceneObject
TSStatic
TSShape
TSShapeInstance
Item
I'm sure they all have their purposes but I don't know when I'd use one class as opposed to another. I find this part of Torque *really* confusing.
Thanks!
04/07/2005 (9:43 am)
See, I told you I was feeling stupid. :-)I was getting myself confused about the right way to do this. Initially I had wanted something that only existed client-side, so I was using the "client-side only" TSStatic resource here:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6504
That's where the ConsoleFunction above came from. But then I realized I needed the object to be server-side as well, so I just modified the ConsoleFunction to make a regular TSStatic. But I'll do it the normal way from now on. :-)
I didn't know about the Item class, so I'll try using that instead. But now I'm wondering: TSStatic objects can be moved around in the Mission Editor, so how does it do it?
Also, is there a good resource somewhere that explains the differences (and relationships) between:
ShapeBase
StaticShape
ShowTSShape
SceneObject
TSStatic
TSShape
TSShapeInstance
Item
I'm sure they all have their purposes but I don't know when I'd use one class as opposed to another. I find this part of Torque *really* confusing.
Thanks!
#4
04/07/2005 (4:08 pm)
Thanks, Stephen. I hadn't seen that before. I'll have to save that to my Favorites. :-)
Associate Kyle Carter
You could add some fairly simple networking code to 'em, or use something like Item which does deal with it properly.
Why aren't you just saying...
new TSStatic { shapeName = ""; position = ""; rotation = ""; scale = ""; }?