Page 1 of 1

Manually swinging a rigid body

Posted: Sun Jun 03, 2012 6:24 pm
by DestroyerOfCities
I have a rigid body that I want the character to use as a weapon. It's a sword, so the character should swing it around and be able to interact with things while doing so. I have the basics set, I nullified gravity for it and set the origin and rotation based on where I want it to be. I'm experiencing a few issues though, and I was wondering if anyone had any thoughts.

First of all, right now my "character controller" is just a basic camera that can move straight through other objects. I have a ground plane for instance, and when I fly through it, I can look up and see that the sword is stuck along the plane. This is okay, but when I then fly back above the plane, the rigid body is stuck at the same offset way up above the camera! Furthermore, it seems to be gradually drifting upwards now. Is there a way to reset this so that it won't go haywire on the off chance that I try to set it's origin to an impossible physical location?

Second, I don't want the rigid body to absolutely wreck everything it comes in contact with. Right now to swing it, I just manually set it's rotation for each point in the swing. How can I get a more physically proper swing with gravity turned off? I'd like to have the sword knock over boxes, but bounce off of stone walls. I thought of setting a collision callback, but then I'd have to manually simulate the rebound. This isn't too terrible, but does anyone have any ideas for a better way to swing it?