[Closed] Cleaning up a biped function
I’ve got a function that gives me the x,y,z position of a Biped/CS bone, but it’s UGLY. It works, but it’s always annoyed me that it felt so hacky.
It basically converts the biped information into a string, parses it, then rebuilds the x, y and z components into a point3.
Can anyone suggest a way to clean it up?
fn getbipedpos bipbone = (
– taking in a bone, convert it to a string, parse the position
print bipbone
bbs = bipbone as string
t = filterstring bbs “[”
co = filterstring t[2] “,]”
xc = co[1] as float
yc = co[2] as float
zc = co[3] as float
p3 = [xc,yc,zc]
return p3
)
$.transform.pos
will give you the world pos of the selected object, be it a biped object or any other.
if bipBone is a variable storing a biped node, then
bipBone.transform.pos
will give you its world pos
Fantastic! I only discovered the $.transform.WHATEVER a few weeks ago when trying to get rotation information. I’d not even considered that’d work.
Thanks again for this – I realised that it made even more sense to make it in a generic find position script, so that it works with any object and not just biped (it already does simply by using your OBJECT_HERE.transform.pos , so I’m changing the name of the function to make it more obvious that it’s not just about biped now.
In fact, I’ve decided to update it so that it will be used in my bone creation, so I’ll pass every start and end point to it. To make it more generic, I’ll allow it to accept point3 values as input and simply return them unchanged.
or you could just use
biped.gettransform $ #pos
there are a load of biped methods exposed to MXS in the “Biped Transform Methods” topic.