Beam firing different angles not working properly

OkyshoOkysho Member Posts: 158
edited January 2012 in Working with GS (Mac)
Ok if anyone bothered to read my last thread, I'm working on a beam weapon for my cannon game, but when I try to fire it at multiple angles the beam sweeps across the entire screen, sideways (based on the angle) I've based my code off of TshirtBooth's health bar tutorial.

My modified rules are as follows:
Photobucket
The first change attribute changes to game.Player1X + (self.Size.width/2)

after messing around for a day I've figured out that the rule I've turned off (The first "change attribute" rule) is the main source of the problem, but I don't know at all how to fix it. Any ideas please?

Comments

  • OkyshoOkysho Member Posts: 158
    bumping for great justice
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    Not sure how to help your specific situation, but here is a demo laser cannon I made:
    http://speedy.sh/m5sut/laserAndMirrors.zip

    Instead of directly manipulating position.x, it spawns an actor with the same rotation as the barrel of the 'emitter' (er.... cannon). Then the beam is sent traveling off at a speed of 500, in the direction of its current rotation.

    There is a bit of extra stuff when the beam hits a mirrored wall. It's direction of travel is reflected (it bounces). Then the beam's rotation needs to change to to the new direction it is traveling. That is done by changing its rotation to: vectorToAngle(self.Motion.Linear Velocity.X,self.Motion.Linear Velocity.Y)

    Anyway, its there for you to use if it helps.

    RThurman
  • OkyshoOkysho Member Posts: 158
    Haven't tested it in my own game yet, but your description and testing the file you provided, it looks like that's exactly what I'm trying to achieve
  • OkyshoOkysho Member Posts: 158
    Awesome! with a few modifications this worked exactly like I wanted. Big help RThurman!
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    Glad it worked for you!

    RThurman
Sign In or Register to comment.