How to constrain turret movement to a limited degree. not full 360 degree rotation

0 favourites
  • 3 posts
From the Asset Store
Grid Movement 1 Engine
$3.75 USD
75% off
A template for a grid movement , grid tactics type game like Dofus , click on the grid you want to move to and the
  • I have a pretty good grasp of the turret behavior and it's working well but each of them are doing full 360 degree targeting and i'd like to limit it to say.. 180 degrees or even narrower ranges.. otherwise still just trying to target whatever is within range AND within a certain degree of rotation range.

    Maybe there is some way to determine the angle of difference between two objects? and i'd need to compare something like:

    1. is the object an enemy?

    2. if it is an enemy is it in range?

    3. if it is in range, is it within the angle of attack based on the current turret in question

    4. if it is, then fire..

    My close to successful approach was simply to compare the X of the turret with the X of the enemy.. this worked fine with a single target, but things got weird when I had to then compare multiple enemies. I made a family called "Enemy" and compared the X of that enemy class and it works pretty well even with multiple targets but i hit some snags where it still didn't perfectly right..

    I wanted to try and use families because it seemed like the better way to handle many enemies rather than making a bunch of unique unit objects with their own variables, etc..

  • Here you go:

    dropbox.com/s/spp1897499j3puc/TurretLimitedAngle.c3p

    You will need to remove enemies from the turret's targets, and acquire/unacquire each target instance with events.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • this is awesome! super helpful. i need to spend some time examining it but definitely spot on!

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