autotargeting

RocketBrainRocketBrain Member, PRO Posts: 269
edited November -1 in Working with GS (Mac)
ok i'm a bit frustrated. i've searched through the tutorials and tried a couple of ideas of my own between range based and overlap/collide but i cant get it to work quite right.

Basically the goal is to have a "gun" rotate towards and fire at a target that gets within a certain range of it. Then when that target is destroyed or leaves the range, the gun finds a new target.

Really getting frustrated as i have a whole slew of game ideas ready but none of them will work if i cant get this to work. Can anybody help me out or point me to a demo?

Comments

  • BlackbirdStudiosBlackbirdStudios Member Posts: 493
    RabidWeasel said:
    ok i'm a bit frustrated. i've searched through the tutorials and tried a couple of ideas of my own between range based and overlap/collide but i cant get it to work quite right.

    Basically the goal is to have a "gun" rotate towards and fire at a target that gets within a certain range of it. Then when that target is destroyed or leaves the range, the gun finds a new target.

    Really getting frustrated as i have a whole slew of game ideas ready but none of them will work if i cant get this to work. Can anybody help me out or point me to a demo?

    So essentially you are trying to make a tower defense game? Have you tried getting the gun to follow the x and y coordinates of the target???
  • oldefaitholdefaith Member Posts: 23
    maybe try this logic

    make attribute Boolean name it "selected"

    then on actor make a rule

    when button is pushed, or mouse button is down and inside "enemy"

    change attribute "selected" to true

    change image to any image probably one with it being selected

    then in otherwise have a change image to the unselected image
    and add a change attribute "selected" to false

    then use the firing ability u have to have the bullett follow the actor using follow bullets x,y

    this is my way of doing it hope it helps
  • RocketBrainRocketBrain Member, PRO Posts: 269
    yeah that hasnt been an issue. And yes a TD is something i'm interested in but not all of it.

    I can get the gun to track the first thing that enters the area but for the life of me i cant get it to target again after the first one. One of the most recent attempts i have the targets going to 4 waypoints around the screen, each being able to take two hits but its not working. i think i'm making it too complicated.
  • RocketBrainRocketBrain Member, PRO Posts: 269
    no oldefaith. the gun needs to do it all by itself without the player controlling it.
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    RabidWeasel said:I can get the gun to track the first thing that enters the area but for the life of me i cant get it to target again after the first one. One of the most recent attempts i have the targets going to 4 waypoints around the screen, each being able to take two hits but its not working. i think i'm making it too complicated.

    OK -- if you can get the gun to track once, you can get it to do it again.

    Try making a game attribute called "trackingOn". Set it to 0 (or false if you made a boolean). Then when an enemy is in the tracking area, change "trackingOn" to 1 (or true if boolean). Then have a rule that says when "trackingOn" = 1 start aiming and firing on the enemy. When the enemy is destroyed, change "trackingOn" back to 0, and wait until the next enemy enters the tracking area.

    Or is the issue a matter of designating the next target? In that case, you could try something like when an enemy enters the tracking area, it needs to start broadcasting its position to a set of game level attributes. (Perhaps called "targetX" and "targetY".) The gun then fires at these coordinates.
  • RocketBrainRocketBrain Member, PRO Posts: 269
    thats fine with one gun.....but when i add another one both guns seem to track the first target even if the second gun is out of range.
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    Oh -- so this isn't a problem of multiple targets, its a problem of multiple guns?

    Same concept though. Each gun would have its own 'kill zone" (for lack of a better term) with its own game level attributes associated with it. When an enemy enters the kill zone for that particular gun, the enemy starts broadcasting its position to some global attributes that the particular gun is tracking.

    Here is another way to explain it. Think of each gun as a separate mini game. If you have four guns in the scene, it will require four separate sets of sensors and attributes.
  • RocketBrainRocketBrain Member, PRO Posts: 269
    Now we're getting there.....however to throw some more confusion into the mix....

    Imagine the user is able to put multiple versions of the same gun into play, each one is going to have to work independently against multiple targets being generated.

    its tough. i've got paper everywhere from ideas being scribbled and many saves alternate saves of trying things out.
  • mu-kowAPPSmu-kowAPPS Member Posts: 233
    Well... U can have an invisible square (collision shape circle) that is constrained to the target. Once the turret 'overlaps or collides' interpolate rotation vector to angle turretx-enemyx,turrety-enemyy +360

    That way it will stop tracking when out of zone. Not sure if it will fit the needs of your game

    Hope this is helpful!
  • RocketBrainRocketBrain Member, PRO Posts: 269
    hahahah genius. have the range based on the target not the gun......i'm going to have to try that.
  • mu-kowAPPSmu-kowAPPS Member Posts: 233
    Glad I could help with my first forum post. Im in the middle of making a game that has enemies rotate towards, move towards and fire at main character all based on overlapping with an invisible actor constrained to main actors x an y.
Sign In or Register to comment.