[pre release] Turret Behavior

0 favourites
  • Hello everyone! I'm here with my second behavior, this time the turret.

    This is just a pre-release for you guys to comment and see if I forgot anything and make feature requests and change requests. Some things don't work, like the "is rotating" condition, or the "when not aiming" property. I'm just rushing this out the door because I don't have much time to work on it, but as you can see, the major stuff is done.

    I have included an example with the file, which you can also preview, live, at http://dl.dropbox.com/u/39044660/Turret/index.html, courtesy of dropbox

    The link for the behavior and example:

    <font size="4">Download Turret Behavior</font>

    Remember the behavior is not optimized, therefore might run sluggishly for big projects.

    Also, this is a behavior, not a plugin, so it should be extracted to the BEHAVIORS folder, under a "turret" folder of the appropriate name.

  • <font size="5">Updated </font>- use the link above to grab the new version

    Added: condition: pick closest object

    this will pick the closest object within the arc/range specified.

    Added: condition: is ready to fire

    true when the object is facing its target, within X degrees.

  • that's really great. i tried this with logic blocks, but it was a mess. thanks for posting your work.

    but you should change the first line in the "License.txt" ;)

  • Checked it out on your example page, excellent work! I'm intending to test this as soon as possible.

  • Um.. If I add the turret behavior to my turret sprite, then add event for the turret sprite--> Check for object within range, then add action: Set turret target to "Ship" Preview windows goes all gray. If I delete the turret behavior, the preview screen shows the game finely.

    The turret behav. example capx also gives a grey preview window.

  • that's strange. You mean the original, unmodified example that goes with the file also makes the screen go gray?

    I'll have to check this, but I can't work on it til monday!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • By invoking major functions, check within range, etc. it gives gray preview in firefox 5.1.

  • Does it work in chrome / firefox 3.6 / ie?

  • If you get the "grey preview", hit ctrl+shift+j in most browsers to open the error console - if you copy/paste any error messages out from that, it's always handy for the dev to know.

  • Thanks for the behavior Fimbul.

  • Error: assignment to undeclared variable i

    Source File: localhost/Turret_behavior.js

    Line: 256



    Line: 256 Col 1:

         for(i = 0, len=instances.length; i < len; i++){ //iterate through instances

    I wanted to fix these errors, but Fimbul is on top of it, you see it better through. Also I began to create my own turret behavior just to get hang of coding again, plus I need to create a slow custom movement for my destroyers.

    Thank You for the shortcut, Ashley!

  • for(var i = 0, len=instances.length; i < len; i++){ //iterate through instances

    Should fix it.

  • Okay, "for(Var i =".. then comes the error:

    Error: this.targetUID is not extensible Source File: localhost/Turret_behavior.js Line: 323

    Anyway, fixed it. Now turret behavior works.


    But Fimbul will change the runtime, so this was only a debug exercise.

  • fun. I can't reproduce it. It's probably due to the way firefox handles strict modes - it works ok on my end. I'll see if I can get some browsers to error out on me.

  • IE9 doesn't support strict mode so will let you get away with strict mode errors. Try on the latest Chrome - I find their dev tools are best anyway.

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