shoot only within values

0 favourites
  • 7 posts
From the Asset Store
A shoot template with ragdoll effect and enemy see you.
  • hello :D

    I'm trying to make an "ai" that will only shoot at you when you are in it's "attack angle-range".

    I've already worked out like 90% of it, but I have a problem!

    i'm using x.angle and angle(x1,y1,x2,y2) in the "between values" condition. I increased the x.angle to each side so it's not just the 1 degree. it looks like this:

    Value:       round(angle(mob.x, mob.y, player.x, player.y))

    Lower bound: round(mob.Angle)-5

    Upper bound: round(mob.Angle)+5

    And it works (almost) perfectly :D! that, with some good-enough "set angle to you", makes a mean shooter.

    The only problem is that the "angle between objects" counts from 0 t 180 and from -180 a 0. while the "object angle" is all 360 degrees. So it means that the AI can't shoot up =(!

    my first attempt at solving this was to make all the numbers absolute... but there is still the issue that i will never get a match over 180 degrees. I'm also thinking that there must be a mathematical solution to this, but i'm not that good with maths.

    and i wonder... why does the "angle between object" counts like that and not in normal 360?? is it a feature or a mistake? :S

    i'm gonna try now to "trick" the game into working this by setting the ai mirrored when looking up.. so it will never actually have to be looking up... hope it works. EDIT: it doesn't >_<! (i'm gonna try mixing values now...)

    here is the file i'm testing this on =) <img src="smileys/smiley19.gif" border="0" align="middle" /> <img src="smileys/smiley19.gif" border="0" align="middle" /> <img src="smileys/smiley19.gif" border="0" align="middle" />

  • i have recently been looking at the "is between angle" system , and had many difficulties, but now i found how to do it and can be used very well in this example


  • i have edited your capx and hope its what you want i made it with 1 event:

  • vtrix that is just perfect!!! thank you soo soo much :D!!!!! pure love to you :D!!!!!!<img src="smileys/smiley31.gif" border="0" align="middle" />!!!... and I feel embarrased, it seems really simple the way you did it :D

    now i wonder how many times I've overcomplicated stuff like this D:

    you gotta be trolling me with that? ?? thanks anyway ^^

  • isn't that the problem? :P it shoot when you are in his range ...

    but i have an idea why don't you put a sprite on the enemy as the range and when the player in that sprite it will shoot and make that sprite with 0 opacity or even you can make it like a light this will be more easier than what you do ^^

  • haha, i thought of that, but i wanted a proper clean solution :D

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • glad you like it :)

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