This forum is currently in read-only mode.
From the Asset Store
10 isometric and animated Strategy Game Buildings in two Colors.
  • I'm having trouble, I'm having two bases spawn a lot of dots and send them at the other base. If they hit another dot, they die, and it works great.

    Now, I want to get the dots to chase enemy dots if the enemy dot gets within a certain range. I'm using the RTS movement...and I can't figure out how to do this.

    Say I tell a red dot to locate it's distance to blue dot. Well each color is an army of dots, but there are only two sprites. Getting the distance to "blue dot", is not sufficient, as there are about 40 blue dots. I need the distance to the NEAREST blue dot, then I need that dot's ID so I can chase it.

    It'd be a little easier (I think), if the LOD movement had a range. I tried using turrets but that seems like a waste of resources. I'm sure there's a simple, event based way to do it. Any ideas?

  • This should probably go in Help/Tech

    Anyway, you could try something like this:

    +For Each dot
    +enemyDot is within # pixels
    -Set dot.closestEnemy to 999999999
    -Set dot.chaseMode to "On"
     +For Each enemyDot
      +Distance to dot is Less than dot.closestEnemy
      -Set dot.targetX to enemyDot.X
      -Set dot.targetY to enemyDot.Y 
    +dot.chaseMode = "On"
    -Move dot towards (dot.targetX, dot.targetY) (or however you do it with rts movement, I don't know, I'm not on my Construct computer right now)
    This will insure that the enemy dot with the shortest distance will keep their target coordinates in the first dot's targetX and targetY variables.  Then you just move the dot towards that.
  • I would give the turret movement another shot - it does the range checking for you, and it does it very fast and efficiently (it's compiled, optimized C++ code inside the plugin rather than events). So on the contrary, it would be a waste of resources to get it working with events when the turret movement can do what you want!

  • That would be ideal but the turret object needs a base object, and for the amount of objects I need...having two rather than one is pretty inefficient.

    They need pathfinding, and I've tried assigning both RTS movement and Turret movement to a sprite. When I do, Turret movement disappears after I add it.

  • The turret object doesnt require a base object - it just enables the turret to rotate realistically with the base, if there is one. It's optional.

    I can add both an RTS and Turret movement to an object... is there some kind of bug with that?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yeah, theoretically it'd work, but I add RTS, then I add turret, then I go to the event sheet and make all the events. Then I go back to the layout and turret has disappeared from that unit's movements. It just vanishes.

  • Ok this is really weird...now I have a bug where my RTS movement is simply not working. Their max speed is 250, they have received TargetX and TargetY, (I made sure by debugging and watching them.) They are not moving at all though. Speed is 0. That is the only movement they have, and they are not receiving any orders, only one when the application starts.

  • Can you send the .cap doing that to ?

  • I got it working for the time being...it's working pretty good now actually. Once I figured out that the function that detects it automatically references the unique ID of whatever it found to the actions I tell it to do. (I was thinking too hard.) The turret movement finally "stuck" and stopped disappearing, and I added the targets and initial move sequence to the "On Layout Start" instead of "On Application Start". It's flawless now.

    Now all I have to do is figure out a way to get the AI controller to choose multiple paths through the level to get to the objective instead of the same straight line every time, using waypoints. However, that'll be on my own time and is unrelated to this problem.

    Sorry to bother ya.

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