I'm working on a top-down spaceship game which has auto-tracking turrets in it, and I've hit a snag.
My ship has a body, and my turret has a body, and they are connected together by a Revolute Joint.
I want the turrets to turn with the ship, as well as being able to rotate to face their target.
Putting friction on the joint would be the ideal answer, but I can't find an option for friction on a revolute joint, and the FrictionJoint isn't coming out until 0.8.0.
What other options do I have?
I have attached the current build of my game to show what my current system is like. You can control the blue spaceship with WASD to move/turn and space to fire the main gun. Camera controls are the cursor keys for panning, Q and E for rotating, and numpad +/- for zoom, and numpad 0 to reset rotation/zoom.
Edit: On diving through the box2d documentation, a recommended way of doing friction with revolute joints is to set the joint's motor speed to 0 (motor will try to stop one body rotate with respect to the other), but implement a maximum torque, so that turning the turret overpowers the motor.
How to make a turret turn with its ship?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
How to make a turret turn with its ship?
- Attachments
-
- lvspace.love
- (22.95 KiB) Downloaded 170 times
Who is online
Users browsing this forum: No registered users and 5 guests