QUESTION] How to replace shapes ingame?
by Tobias Baumann · in General Discussion · 02/19/2007 (8:52 am) · 3 replies
Hi everyone,
i hope someone can help me:
Lets say I want to replace a shape with another one ingame when the player clicks the mouse while that shape is under the crosshair of the player.
What files do I need to change?
I have done the basic torque tutorial and i got some insight but I dont know how to do this.
Regards
Tobias
i hope someone can help me:
Lets say I want to replace a shape with another one ingame when the player clicks the mouse while that shape is under the crosshair of the player.
What files do I need to change?
I have done the basic torque tutorial and i got some insight but I dont know how to do this.
Regards
Tobias
About the author
#2
thank you very much.
Do you also know how I can track at which object the User is pointing with his Crosshair?
02/19/2007 (2:00 pm)
Hmmm, I guess I will look into the setDataBlock function. Values such as rotation, scale etc. of the placed 0bject remain the same if u change the dataBlock right?thank you very much.
Do you also know how I can track at which object the User is pointing with his Crosshair?
#3
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=9687
for anyone else interested
02/19/2007 (2:41 pm)
I guess I just found my solution :)http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=9687
for anyone else interested
Torque 3D Owner Sean H.
the most straightforward way is to get the position of the first object, move the first object using setTransform(), and then place the new object in that same position using setTransform().
you could also place both objects in the same position and hide the second one using hide(), and when the user clicks the button, the first objects becomes hidden, and the second object becomes visible all using hide function.
a more accurate way of doing it would be to use the same object for both and just switch the datablocks using setDatablock() when the user clicks the screen. the new datablock would point to the new shapefile.
another alternative is to use the same object for both, and use the same datablock for both and change the shapefile attribute for the datablock directly when the user clicks the mouse. the only potential problem with this solution would be that all objects which use this datablock would be affected.
you could also use a visibility animation for this. in the model file, embed both models as separate groups into the same file. hide the second shape by setting the opacity to 0. create a visiblity animation where, over the course of one frame, the first shape's transparency goes from 1 to 0, and the second shape's transparency goes from 0 to 1. then in the engine you would call %shape.playthread() to play the animation when the user clicks the mouse.