How to make a turret turn with its ship?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
maw3193
Prole
Posts: 1
Joined: Mon Jan 23, 2012 3:59 pm

How to make a turret turn with its ship?

Post by maw3193 »

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.
Attachments
lvspace.love
(22.95 KiB) Downloaded 168 times
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 78 guests