Making it swing
by Henry Shilling · in Torque X 2D · 11/03/2009 (8:34 pm) · 6 replies
I have a gun attached to a vehicle, I'd like the gun to swing, like as I turn the gun will swing as if on a spring, passing the target and swinging back, pendulum maybe. Anyway does anyone have any idea how to do that? Here is my code however all it does is half the job, once the gun is in line with the direction of the vehicle it stops.
Any help would rock, thanks
T2DPhysicsComponent _pc = _gun.Components.FindComponent<T2DPhysicsComponent>();
_pc.AngularVelocity = (_sceneObject.Rotation - _gun.Rotation) * 2;Any help would rock, thanks
About the author
http://twitter.com/theBigDaddio
#2
I am actually quite fluent in AS2/AS3 etc. I am so glad not to be working in flash at the moment.
11/05/2009 (3:44 am)
Thanks man those are some pretty cool behaviors. Not exactly what I imagined but really quite useful and who's to say that another way would not be better?I am actually quite fluent in AS2/AS3 etc. I am so glad not to be working in flash at the moment.
#4
The tweens really were not what I was looking for, I wanted more of a physics based motion. I also ended up making it a twin stick shooter but then we never really liked where it was going so it sits there partially implemented, maybe to revisited someday. It was a cool learning exercise at worst.
I have however made a library of components that I was going to share with the community. They are clones of some of the components that come with TGB, and gave me a common start point for working between the two platforms.
I was thinking of putting them on TDN but then recall you guys had some problems doing this?
01/09/2010 (5:26 pm)
The game concept was your vehicle was damaged and your only weapon was swinging freely shooting mostly behind you. Enemies would appear and chase and you had to get them behind you so your gun could hit them. We ended up not really liking the project so I really never implemented the tweens.The tweens really were not what I was looking for, I wanted more of a physics based motion. I also ended up making it a twin stick shooter but then we never really liked where it was going so it sits there partially implemented, maybe to revisited someday. It was a cool learning exercise at worst.
I have however made a library of components that I was going to share with the community. They are clones of some of the components that come with TGB, and gave me a common start point for working between the two platforms.
I was thinking of putting them on TDN but then recall you guys had some problems doing this?
#5
i think that sums it up nicely for the majority of us.
please share your library of components!
what about a blog (resource post) instead of TDN ?
01/11/2010 (3:04 pm)
" never really liked where it was going so it sits there partially implemented, maybe to revisited someday. It was a cool learning exercise at worst."i think that sums it up nicely for the majority of us.
please share your library of components!
what about a blog (resource post) instead of TDN ?
#6
01/11/2010 (6:37 pm)
You've gotta know when to fold em. Editing is the only way to make great stuff. I will make a resource, I guess then I'll have to host them on my site. Nothing too fancy. I'll try and get them up soon as I am on a paying flash project at the moment. Real world once again gets in the way.
Torque Owner DJD
I don't know TX well enough to know whether there's an easier way, but
an easing equation should do what you need. Combine it with a tick handler that sets the angle and you should be in business. Check out Robert Penner's easeOutElastic function in the visualizer here:
http://www.robertpenner.com/easing/
You will need to port from AS2 to C#, but it should be pretty straight forward.
Cheers,
DJD