How do I calculate my laser beam

0 favourites
  • 4 posts
From the Asset Store
This is a pack of 14 animated lasers with different colors.
  • ok this might be a little difficult to explain but here goes.

    its for a 2D side scrolling shoot em up with a fake z axis ( like streets of rage)

    basically ive got a like a laser cannon on tracks that shoots a constant beam of lightning every (x) number of seconds when fully charged.

    the tracks them self's are the z axis position and the turret on top rotates towards the player in a constant beam when firing

    my problem is i need a formula / function that calculates when the bean should stop (beam should not go below the y of the tracks) but move from infront of the player to behind on the same fake z axis ( y axis of tracks) unless told to.

    in a nut shell i need a function that works out the longest length of a 90 degree triangle every tick while the cannon is firing.

    no point in adding a capx as it would just be the laser cannon that can rotate the turret.

    But i can if needed draw a diagram of what im looking for.

    I know the maths to work it out but having trouble converting the maths into a function that works it out.

    really hope that makes sense.

  • found a better way to explain what i mean.

    basicly need a function that calculates the hypotenuse of a triangle every tick while in shoot mode.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You could use the distance() function or use the pythogerian theorem to find the hypotonuse.

    Hypotenuse = sqrt(x^2 + y^2)

  • R0J0hound thank you very very much. will try my best to implement this and post a capx for others to see

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)