[SOLVED]Turret Behaviour ..Arc Limit?

0 favourites
  • 9 posts
  • Im trying to limit the rotation of the turret to a given arc, say +- 60 degrees (set with an instance var). Additionally, the turret is pinned to another object that can also move and rotate freely. Im still not comfortable with C2, so any help would be greatly appreciated :)

  • anybody? :/

  • I added limited fields of fire to a Podpathos capx:

    Limited Field of Fire Turrets

    • orig did not use turret behavior at all.
    • it now uses turret behavior for acquiring target that is in range, predictive aim, triggering the shot, etc.
    • the turret behavior auto rotate feature is disabled and angle of turret is rotated back inside the limit, or back to the base turret orientation whenever it hits the field of fire limit, or when there is no current target.
  • Updated with some info graphics:

    (updated again to show what one turret with Predictive Aim off does... and added field of fire indicators when selecting a turret.)

    Turrets - Limited Fields of Fire

  • Jaycephus - nice example cheers

  • Thanks! Should have mentioned above to click on the turrets to see the info and range graphic.

  • Jaycephus Thanks for your solution. <img src="smileys/smiley20.gif" border="0" align="middle" />

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You're welcome. I needed the feature myself, so I searched and found a Podpathos capx that demonstrated limited fields of fire, but implemented the turret directly in events rather than using the behavior. I wanted to have predictive aim, firing rate, etc, from the behavior, so I modified it to use the behavior and still limit the field of fire.

    To demonstrate the effect of turning Predictive Aim off, I updated the latest version of the capx above to set Predictive Aim off on the third turret from the left. For this pattern of targets, and the velocities involved, it never hits a target, ever. I also added field of fire indicators to the range indicator when you click on a turret.

    I think limited fields of fire is the only really needed thing missing from the turret behavior. Perhaps an option to limit the detection area to the limited field of fire as well. Also, having a detection range that is longer than firing range might be nice, since you can almost always see the target before it is in range. But that can easily be implemented in this capx by simply setting the bullet.range at time of spawn to something like turret.range * 0.5, and then doubling the turret range. The problem of detecting enemies behind turret, outside of the field of fire, would still remain, and be made worse as well. This is bad because the turret locks on to the first target in range in my preferred targeting mode. So for some time it may be unable to fire on the current target, while other targets pass within its field of fire. The solution is probably to monitor the diffangle and distance to the target, and as long the current target is out of range of the actual bullets, force it to unacquire the target (a feature of the behavior), say once a second. Then the turret will re-pick the nearest target, which could be the same target somewhere behind it or out of bullet.range, but at least there is a chance it will re-target something in front of it that is in range. The downside to not permitting the turret to target beyond the field of fire and range of its bullets is that you lose the opportunity to pre-rotate toward the target, which allows it to get more bullets on the target depending on the circumstances. I think most games just allow the turrets to rotate really fast to solve that issue.

  • oops!, have been on in a while. thanks :). I did create a solution but it was long winded and ugly. It involved using a placeholder node, an invisible node that is parented to object you want the turret pinned to.. this represented the original orientation of the turret, and through an instance variable i could arc limit based on the angle between the target and this invisible node.. and rotate the turret to match this nodes orientation when the target was lost.. my construct skills are shockingly bad.. but anyway, thanks for your help :)

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