How do I make a laser? HARD CHALLENGE

0 favourites
  • 4 posts
From the Asset Store
Control your space ship in a weird space-time environment and destroy as many enemies as you can!
  • Hello there. Hugs from Brazil :)

    So, I want to make an enemy that summon a giant laser in the direction of the hero, but that laser gets smaller or bigger depending of the distance between the wall and the enemy

    If you don't understanded, I will explain better:

    There is an enemy that walks (using the pathfinder), and he has a laser. If the enemy is 100 pixels away from the wall, the laser gonna be 100 pixels width. If the enemy is 15 pixels away from the wall, the laser gonna be 15 pixels width.

    The only help that I need is to make the multiple-sizeble sprite (laser). Don't need help about the enemy's behavior.

  • If you use the expression distance(enemy.x,enemy.y,wall.x,wall.y) this will give the value of the distance between the two and I guess the size value for the laser.

  • The idea is you start at the enemy and move by steps toward the player and stop when a wall is hit.

    You can do all the steps with a loop.

    Here’s one such example. The max width of the laser will be 300.

    Every tick
    — set laser position to enemy position 
    — set laser angle towards player
    —set laser width to 0
    
    Repeat 300 times
    — set laser width to laser.width+1
    — Laser overlaps wall
    — — stop loop

    Alternatively you can use the ray cast feature which will give you the position where a ray hits an object. The just use the distance expression between that point and the player.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Or use raycasting feature of the Line Of Sight behavior.

    https://editor.construct.net/#open=instant-hit-laser

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