[font=Arial]I’m making a top-down space game and I’m having trouble trying to align the lazers that my ship fires, with the point where they’re fired from.<o:p></o:p>[/font]
[font=Arial]<o:p> </o:p>I’m calling the attach function from an object called shipgun, buried within the player object.<o:p></o:p>[/font]
[font=Arial]The player object itself is in an object called game, within which shipgun is intended to attach lazer objects, so that [/font][font="]_root.game[/font][font=Arial] is the object that holds all the active game elements (the player mc, enemy mc’s, lazer mc’s etc…). <o:p></o:p>[/font]
[font=Arial]<o:p> </o:p>Currently instead of lazers, I have a tester object (a green cross) to show the origin point of the lazers, except me and flash have a disagreement as to exactly where this should be! <o:p> </o:p>[/font]
[font=Arial]The hierarchy for shipgun is;<o:p></o:p>[/font]
_root.game.player.head.shipgun<o:p></o:p>
<o:p>
</o:p>Inside the shipgun mc, I have this code;<o:p>
</o:p>
[font="]this.localToGlobal(obj = {x : this._x, y : this._y});<o:p></o:p>
_root.game.attachMovie(“tester”, “tester”, 1000);<o:p></o:p>[/font]
[font="]_root.game.tester._x = obj.x - _root.game._x;<o:p></o:p>[/font]
[font="]_root.game.tester._y = obj.y - _root.game._y;<o:p></o:p>[/font]
[font=Arial]<o:p> </o:p>[/font]
[font=Arial]you’ll also notice that there also a shipgun2, which is just a duplicate of shipgun. I’ve done this for now, simply to attach a second tester MC to _root.game for the second gun.<o:p></o:p>[/font]
[font=Arial]<o:p> </o:p>
I expect the origin point for the lazers (the “tester” mc) to be exactly on the centre of each gun barrel, except they’re just off center!? Also the distance between each “tester” mc is wider than the distance between shipgun & shipgun2!?<o:p></o:p>[/font]
[font=Arial]If you rotate the player, the tester mc’s seem to lag behind shipgun objects, and they seem to be adversely affected by the zoom!?<o:p></o:p>[/font]
[font=Arial]<o:p> </o:p>
It’s not as bad as it sounds. I know the answers going to be something simple and it’s just something I haven’t taken account of, but I’ve hit a blank and just can’t see what that might be!<o:p></o:p>[/font]
[font=Arial]Could someone please, please, point me in the right direction! Do I have to use localToGlobal on other co-ordinates within the hierarchy, am I not including co-ordinates I should be within my equations, or is the scale and zoom coming into play in ways I don’t expect!?<o:p></o:p>[/font]
[font=Arial]<o:p> </o:p>thanks<o:p></o:p>[/font]