Game Development Community

changing the pivot-point of an object

by Isaac Barbosa · in Torque Game Builder · 10/21/2009 (1:30 pm) · 6 replies

Hi,

I want to ser autorotation for an object. The problem is that it rotates by default taking as pivot the center of the object itself.
is there a way to change its pivot?
Thanks
Isaac

#1
10/21/2009 (1:39 pm)
i remember you can do that in the editor... and somehow, i think i saw a command for that in the documentation... setLinkPoint or something like that...

its possible, for sure (i've done it... i needed to set the pivot point of a turret... long ago), i just dont remember how right now.
#2
10/21/2009 (3:15 pm)
@Ehrlichmann,

Thanks for your answer. Sadly, I don´t know how to implement that right now... some one else?

Isaac
#3
10/21/2009 (3:51 pm)
i'll look into it... and drop you some snippet.

esit: i've looked into it...
while in the editor, place a sprite into the edition pannel, and while that object is selected, hover the mouse pointer to it... a menu will appear over that object.

there will be an option named "edit this object sort point", if you click on it, the bject will zoom in, and will show you a blue dot on the center... move that dot to wherever you want, and now thats the new "center" (pivotal point) of the object...

i'll look into the docs and tell you how to do it thru code.
#4
10/21/2009 (3:55 pm)
thanks!
#5
10/21/2009 (4:02 pm)
sometimes i wish i had all the demos i've made the last 2 years with me all the time, so i could take a glance at the code, and post the snippets w/i having to look to the docs... hehe.
#6
10/21/2009 (4:16 pm)
ok now... i've taken a look at the docs, and here's what you're looking for:

1st and foremost, since its been awhile since last time i worked with this, you will have to experiment some to get it working properly ok?...

now, lets get down to bizz...
you will need this commands to work with it:
/*this will create link points on your object... they will help you mount your object to another object, but in case you dont want your object to be mounted in the very center, you can modify the offset..*/
%this.setLinkPoint(%mountid, %offsetX, %offsetY);
/*this part will help you mount your object... just make sure you remember the linkpoint id*/
%this.mount(%parentObj, "0 1", 0, true, true, true, true);
//this modifies the sortpoint at runtime
%this.setSortPoint(%x, %y);

as you can see, there are some ahndy commands for you to achieve that... just remember, when using setLinkPoint and setSortPoint, you're not working with world varibles (liek the whole scene) but local object variables (the object size) if you know what i mean.

now, if you wanna mount your object directly to a certain known link point, you can use the mountToLinkPoint() ... the parameters are the same than the mount command.

sorry if i didnt actually gave you a working snippet... but with those commands you can get the job done... i know, i did more than a year ago.