I’m having a weird issue with .alignAxisToVect. The pivot points of the guns turn correctly as long as my ship is pointing at what appears to be X 0 on the global plane, but if I rotate the ship, they seem to continue pointing in that direction (they will eventually seperate from the main base of the gun … making it look like a wheel without hubcaps lol) … and for the life of me, I cannot figure out why. This has been happening for several days now but I didn’t really think much of it until I noticed it again today, and it bugs me. Any help would be appreciated.
the python script (attached to the pivoting point of the guns, note that this is not the barrel. gun has 3 parts … think of this as the middle part):
import GameLogic from mathutils import Vector controller = GameLogic.getCurrentController() obj = controller.owner ship = GameLogic.ship_data[obj.parent.parent['tag']] if not ship.target == None: tracking_speed = obj.parent['tracking'] target = ship.target.position - obj.position turret = Vector([0, 0, 0]) turret.rotate(obj.orientation) # align the turret, local Y axis should be locked :/ if obj.parent['sense'] == True: obj.alignAxisToVect([turret, target, target], 2, tracking_speed)
showing that they remain normal, and correctly rotate towards the target without seperating if the ship does not rotate:
and when the ship rotates, this happens.