jwoods's Forum Posts

  • Katala, thanks for the reply. Is line of sight a built in function? Is this a Turret characteristic?

  • Hello again,

    I need to calculate the line-of-sight distance between two objects (I think).

    Background

    I'm currently hacking up the RTS template to learn more about events with C2.

    I currently have Enemy tanks only returning fire once fired upon by a friendly tank. I now want to add some extra Enemy AI which will allow an Enemy tank to detect any Friendly within it's shooting range, who is also shooting, and then engage.

    See image below;

    In this example there are two Enemy (red) tanks within range (for simplicity I've highlighted the range of the Friendly tank - but in reality this is Enemy centric). What I want to accomplish is these two tanks detecting that the Friendly in their range is shooting, and to begin engaging it.

    My thought for achieving this is;

    For each enemy unit that isn't firing

    • find closest friendly unit
    • Calc distance to unit (line-of-sight)
    • if distance <= range AND friendly is firing then ATTACK!!

    This only gets me the one closest Friendly to the enemy - there could be more friendly in range attacking, but since i can only attack one at a time, this is good enough.

    Problem

    How do I get that distance figure, and how do I ensure it is line-of-sight and not including a random path route distance?

    Any thought appreciated.

  • thanks for the explanation blackhornet

  • I've created a button which is pinned to a sprite (to create a context menu).

    In the layout I make the button width 165 and the grey sprite is 175 in width;

    however when I run the game up the button is now wider than the sprite;

    Any ideas on what I've done wrong?

  • Are you sure your health bars are also in the same container with your tank bases and turrets? (Just putting health bars in a separate container will not work, the container must have tank base, tank turret, and two health bars)

    That's a really good point, so I add my health bar components to the same group as the turret and base;

    It's working now - but It appears that the assignment of a health bar is pretty random.

    Do I need to delete and recreate each tank to bring the UID's closer together?

    UPDATE

    Deleting all the tanks and recreating them from (copy in memory) has done the trick, thanks for your help Windwalker.

  • Hello again C2 community.

    Every time I think I'm getting the hag of the event system I try something out and POW, back to square one.

    I'm using the RTS template, and am currently trying to create health bars for my individual units.

    I'm trying to follow the same method used in the template to tie health bars to bases as is used to tie tank turrets to bases;

    So I create my health bar from 2 sprites, put it in a container and use the same technique (initially with just one health bar), and it works great;

    However all health bars seem to just stick to the one tank base. I don't understand why the technique works fine for tank and turret but not for me new health bar.

    Sorry, I can't include urls (to capx) due to my low cred. But I hope the images will show.

  • Thanks Zetar, I wasn't really expecting it to work like that so I hadn't looked in objects.

    Thanks blackhornet, yes as Zetar points out it is standard now.

  • jwoods can only post plain text URLS when they have 300 rep. 1 URLS removed. Why?

    Hi,

    I've read in the manual it's possible to add functions to reduce the repetition of actions within events.

    I'm probably going to feel pretty stupid when someone tells em the answer, as I'm sure it's simple, but I can't for the life of me figure out how to add them. In the event viewer I assume they are a type of event, Can't find them under System or anywhere else when adding an event?

    Any help appreciated.

  • Thanks again Guizmus. This makes complete sense, thanks for taking time to help and explain the fix.

  • Hi,

    I'm still messing about with the RTS template (in-case you've seen my other posts).

    I'm having trouble with my Friendlies when I set two or more to attack Enemies at the same time.

    Scenario: I select one Friendly and send it off to attack an Enemy. I then quickly clear selection, select a different friendly and send it off to attack the same or another (behaviour the same). Whichever one reaches an Enemy first will start attacking, the other will simply stop on it's path.

    From this point the first Friendly becomes 'dominant' and whenever it is given the same target as another Friendly the other friendly will not attack the enemy, even if it reaches the target first.

    capex

    Pulling my hair out here. can't seem to see what I've messed up.

    In debug I see the vars congaing the states seem fine, but event just don't fire.

    /Jamie

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks Katala, this worked great.

    /Jamie

  • Hi,

    I want to stop my sprite moving along a path when a specific distance from the end is reached (i.e. 300px from end point). Is this possible?

    /Jamie

  • Hello,

    I'm currently working from the "Template: Real Time Strategy (RTS)" template.

    I'm still trying to wrap my head around the event sheet block model.

    I want to implement the following sequence;

    1. User selects Friendly unit(s)

    2. User selects Enemy unit

    3. Friendly calculates path and moves along it

    4. Friendly stops at the expected end point

    5. Friendly begins to fire.

    Problem: I'm having trouble with item 5. I have a event to move the Friendly (this stops at the value set in the family varialbe "Range" as I want) However the combat event seems to get called to early and the Friendly doesn't attack when it reaches it's end point.

    I've tried moving the attack block as a sub-event to the move, but it still doesn't help.

    How would I have the Friendly move and then wait until it stops to begin attacking?

    capx

    Any help appreciated.

    /Jamie

  • Probably need to look at range in your turret behaviour. Set at 300 at the moment...

    Thanks again RamPackWobble.

    When I increase the range this resolves the issue, thank you. However, the Friendly start shooting while it's way too far from the Enemy who is out of actual range for damage.

    I think I might try to detect when I'm close to the enemy before I begin attacking.

    Thanks again for your help, this was really useful

  • Hello,

    I'm currently working from the "Template: Real Time Strategy (RTS)" template.

    I've modified the standard Event sheet to;

    * prevent Friendly and Enemy units from attacking each other (disabled both actions in event 2),

    * I've made it so that my (selected) Friendly units will only attack Enemy units I click on by using the "acquire target" action (see block 34 and 35 under Combat group).

    My problem: When I select an Enemy unit and my currently selected Friendly unit is more than around 250px from the Enemy, my Friendly just moves to the location but doesn't attack. If the Friendly is closer than 250px it will engage and attack.

    I can't find anything on the Event Sheet that would be causing this. Note: I'm a total newb.

    capx

    I've searched the FAQ's but nothing really helped me.

    Any help appreciated.

    /Jamie