Turret Issues

0 favourites
  • 5 posts
  • So I'm new to turrets and this is my first time setting one up. I just can't seem to get it working though. I have a Squirrel enemy that I want to throw acorns at the hero so I figured a turret would be ideal as it has targeting and range options. When I set it up nothing happens at all if I have rotate turned off. If I have rotate turned on the squirrel rotates until it's back is turned to me and starts throwing acorns perfectly. I'm guessing there is a way to tell Construct what the front of the turret is, but I have no clue how. And no clue as to why it doesn't work at all if rotate is turned off. On a side note, is there a way to have the acorns destroyed if they collide with anything, not just a specific object?

    Any ideas are appreciated.

    EVENT SHEET

    <img src="http://i526.photobucket.com/albums/cc346/adjustvolume/Event_zps46c0c87f.jpg" border="0" />

  • The right side of your image (in image editor) will be the front.

    Check for collides with multiple sprites: use a family for that OR an OR-block if you are using the free version of construct 2

    no idea why it would work with rotation and wouldnt work without rotation

  • So I found a solution for my specific issue. I decided to can the turret features as they eluded me and just went with good ol' fashion programing to get it going. With this bit of code it allows the player to enter a preset range, the enemy will turn face the player and throw and object that hurts the player. Below is an event sheet on how I was able to achieve it. If anyone has thoughts on how to streamline the code for efficiency please let me know.

    <img src="http://i526.photobucket.com/albums/cc346/adjustvolume/Solution_zpsf12aee97.jpg" border="0" />

    In this, the Hero is the player, Acorn is the throwable object, squirrel is the enemy, and range is an invisible red box surrounding the squirrel.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It is not optimal since every 1 seconds uses the global time, so it will happen that the squirrel will not fire the bullet immediately when you come into range. That might not seem that big of a deal in this case, but in other cases where the time intervall is bigger (like 5 seconds) this becomes really inconsistent.

    I'd prefer a construction like (cd = instance variable of squirrel):

    every tick

    cd > 0: substract dt from cd

    distance(hero.x,hero.y,squirrel.x,squirrel.y) < range AND cd less or equal 0: fire bullet, set cd to (your cooldown time)

  • I did notice what you mentioned that the squirrel does not react immediately when the hero enters the range, which is what I want. I will have to give your code a try and see if I can get it to work better. Thanks for the input it is HIGHLY appreciated, you have no idea.

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