Any good ideas for implement a gravity gun?
Posted: Sat Sep 10, 2011 9:24 am
I'm trying to implement a simple gravity gun which can suck and hold the object at a certain distance away from the camera. When mouse is released, it can launch the object.
My idea is :
1.use a ray to detect which entity is hited
2.set the gravity of this entity toward to the camera if possible. But I didn't find any method to set it so I tried to apply an impulse on the entity toward to the camera the lock it's position when it is close enough. But the entity will keep it's motion state(keep rotating or something). I want it's world matrix to be the same direction as the camera
3.apply an impulse when the mouse is released
I think the second step is not good enough. Any one have a better idea?
My idea is :
1.use a ray to detect which entity is hited
2.set the gravity of this entity toward to the camera if possible. But I didn't find any method to set it so I tried to apply an impulse on the entity toward to the camera the lock it's position when it is close enough. But the entity will keep it's motion state(keep rotating or something). I want it's world matrix to be the same direction as the camera
3.apply an impulse when the mouse is released
I think the second step is not good enough. Any one have a better idea?