Tower Defense... Shooting A Target Near Your Tower

FallacyStudiosFallacyStudios Member Posts: 970
edited February 2012 in Working with GS (Mac)
Does anyone know any good ways to set up something similar to a tower defense? Like if they place their tower down how can I have it registering where the closest enemy is?

(There will be too many enemies to have each of their X and Y cords)

Comments

  • simo103simo103 Member, PRO Posts: 1,331
    maybe invisible actors at a certain distance from the tower and when an enemy collides with it you can trigger your fighting to begin?
  • FallacyStudiosFallacyStudios Member Posts: 970
    @simo103 Ya I was thinking something like that. Only problems I was having is they can place a large number of towers down. Each would have to spawn its own bounding box. I'm not sure how I would be able to set it up so a specific bounding box spawned by that tower actor would work only for that tower actor, you know what I mean. So I could have a tower on the opposite side of the map that when the bounding box on the other side is triggered it starts shooting that far off direction.
  • MotherHooseMotherHoose Member Posts: 2,456
    or … just make the tower with a larger … i.e. have transparent area around it larger

    use: > Physics > Collision Shape > Circle on both enemies and towers

    don't know the maximum towers your player can place in a scene
    you need to store/reference the enemies' X,Y to fire directly at them

    @MotherHoose
  • FallacyStudiosFallacyStudios Member Posts: 970
    @MotherHoose

    Thank you that should work. Is there a way to have them fire the bullets in the direction in which they are touching the enemy? I don't know if I will have a way of storing every enemies X,Y or know which enemy is which
  • simo103simo103 Member, PRO Posts: 1,331
    @FallacyStudios ... is your game a top down game using a grid?
  • FallacyStudiosFallacyStudios Member Posts: 970
    @simo103
    It is a top down, but does not have a grid. Should I have one in there? If so how would I go about doing that?

    The way I am designing it is more open area. Its almost like Warcraft/Starcraft except your troops don't move and you can place them anywhere (with the exception of too close to another character)
  • simo103simo103 Member, PRO Posts: 1,331
    @FallacyStudios ... I'm unfortunately fair from the right person to ask whether it should be a grid .. but I thought it would give you a bit more control and you could plan ahead as you would know the x and y's of all the possible positions of towers if you only allowed them to be 'snapped to the nearest grid point'. You could then also place invisible collision actors around each grid point and have them activated by the tower being positioned in their grid and pre-set their attribute values so they weren't being calculated in game. Might be a wrong direction to go however so you may wish to get other more experienced GS's to weigh in on their thoughts. You could do a detailed enough grid I would think so that the players choice of position would be close to the snap to grid point in most instances.
  • FallacyStudiosFallacyStudios Member Posts: 970
    edited February 2012
    @simo103
    Well thank you. It is definitely worth looking into at the very least. I'll check it out now and see if maybe I can go that direction.

    The only other way it might work would be with a table? You can place information in the tables dynamically and have constrain attributes for each spawned enemy so I know their x and y's you think?
  • simo103simo103 Member, PRO Posts: 1,331
    edited February 2012
    @FallacyStudios ... re Tables ... you can't place info in tables yet they are read only. My thoughts were you have a Tower placed in a grid, say Grid3. You know that Grids X and Y already. You have a number of invisible actors say Grid3_SW, Grid3_WSW, Grid3W etc placed at all the sides and corners on that Grid3. You pass their x and Y to a game attribute on collision with an enemy. You calculate the angle from Grid3 x and Y to Grid3W x and y (for example and fire your bullet in that direction). WOuld be a lot of pre-setup work ... but would be less intensive that all constraints and in game calculations. In case you want to do a limited test here is a template I got from someone a long time ago that should help with the Grids part:

    http://www.funkymunkygames.com/Promo/Snap_to_grid_demo.zip
  • FallacyStudiosFallacyStudios Member Posts: 970
    @simo103

    Thanks. Thats pretty cool. I heard that Code Monkey has a pretty good grid template or something that is designed for tower defense like games. I'm trying to find that and hoping it will solve the predicament.
  • simo103simo103 Member, PRO Posts: 1,331
    @FallacyStudios .... cool ... I found two other grid files that I got somewhere .. perhaps one is Codemonkeys .. anyway feel free to poke in them if you like:

    http://www.funkymunkygames.com/Promo/dragging.snapping_actor.gameproj.zip
    http://www.funkymunkygames.com/Promo/grid_based_game.gameproj.zip
  • MotherHooseMotherHoose Member Posts: 2,456
    edited February 2012
    WOW!
    @simo103 … you sure are giving us some goodies!

    Thanx!

    @};- MH

    EDIT: also √ this one from simo … not on-topic; but wonderful: http://forums.gamesalad.com/discussion/39820/free-template-wheel-spin#Item_4
  • FallacyStudiosFallacyStudios Member Posts: 970
    @simo103 Cool thanks man. I appreciate the help :)
  • simo103simo103 Member, PRO Posts: 1,331
    edited February 2012
    @MotherHoose ... apart from the wheel template posted earlier I'm actually just providing links to demo stuff I download ages ago when we still had access. Glad to provide this help though as the demoes helped me in getting started.
    @FallacyStudios .. no problem!
Sign In or Register to comment.