Game Development Community

Moving Bones with script

by Abraham Hadley · in Game Design and Creative Issues · 05/23/2012 (9:47 pm) · 4 replies

Ok, so my issue is to move a bone with script in Torque3D.

I made a fishing pole. This fishing pole has a skeleton for animating, but I don't want to animate it.

When someone casts the line, I want the bobber to land at the point the user is looking using a ray. On landing, I want the bobber to have physical properties and float on the water. When a fish "bites" the pole will bend a little and the bobber will go under.

I can't use animation for this as the effect won't quite match what I'm looking for. If someone casts at their feet, that's where I want the bobber to land.

So two main things:
How do I move a single bone using script, and
How do I get that bone to have physics so it will float on water

About the author

4 years of Graphics, and 6 years of coding experience.

Recent Threads


#1
05/25/2012 (3:02 am)
I don't believe that's possible without the source code, but with shouldn't be too hard.
How I would go about it purely in script is to have several/lots of animations mimicking correct rod bend angles, then work out the angle from the float to the player plus an offset for the rod tip, then select the animation that best matches.

I don't know a lot about the physics side of things but couldn't you just make the float a physics object with an invisible 'chain' to restrain the movements of the float?

either that or make it a StaticObject / WaterVehicle (is waterVehcle a stock object?) and restrain using schedule to update movements with raycasts?
#2
05/25/2012 (6:10 am)
Is it possible that I can just play animations for a fishing pole while being held? The biggest reason I ask all this is because at the current moment the pole is rigged with a skeleton. If I used animations, the bobber would be on, above, or under the water based on where the player was standing. I want the bobber bone to stretch out to where the player is looking and drop after a certain distance to the surface of the water, or if they cast on land then sit wherever it lands.
#3
05/25/2012 (10:28 am)
I've played animations on ShapeBaseImage's by setting the relevant sequence (stateSequence[]) in ShapeBaseImageData datablock.
Having just looked at the docs I don't think animations can be played by using playThread like other objects, so you'll either have to have the rod and float as part of the player model and hide the mesh when not mounted... or use a separate object for the float like i mentioned above, I don't think your going to be able to get away from having the rod as part of the player model, unless someone who know's better corrects me and says you can play arbitrary threads on ShapeBaseImges.

But either way I think you can forget the idea of using bones without the source.
I hope I'm talking aload of rubbish.. but don't think so..
On a plus side if you do buy T3D there are lots of topics in the private forums and i think resources that would make doing what you want with bones quite straight forward.
#4
05/26/2012 (5:17 pm)
You can mount ShapeBase objects to other ShapeBase objects. All ShapeBase objects can be animated.