JeremyBenson11's Recent Forum Activity

  • Borgi, I tried your formula like this:

    mouseX = enemyUnit.X + cos(random(360)) * random(100)

    mouseY = enemyUnit.Y + cos(random(360)) * random(100)

    Then move towards the location like this:

    set x = lerp(enemyUnit.X, enemyUnit.mouseX, 1 - 0.5 ^ dt)

    set y = lerp(enemyUnit.Y, enemyUnit.mouseY, 1 - 0.5 ^ dt)

    The problem is the each turn the unit seems to move less and less distance, and usually in the same direction. Is there something that would trip this method up? Should I be setting mouseX and mouseY to zero at the end of each turn.

    The game goes player turn move up to 100 px if there is a target in site, fire up to 120px. Same for the enemy unit.

    I know this isn't goo ai at all, but I'm just learning some basic concepts. Knowing how to move set pixels in a random direction is good . I also have to study math.

    I'm gonna check out RamPack's capx now. That seems like a simple and interesting method..

  • What is the best way to move a sprite to a random point within line of sight. Say my sprite has a line of sight that is 100px. How can I pick a random x,y that is a random angle, and then move the spite random(1, 100) PX to a point on the line.

    ugh, math is confusing.

    Basically the sprite can move to one point in any direction, but only up to 100px

  • Ah. I see what you're saying. More of a design issue than anything. Thanks for the info.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I did that. Cursor over enemy unit was added after, as a secondary attempt. This only worked when solid was removed.

  • I just told you what the fix was. I removed solid, and it worked. It wasn't line of sight. I could be 5px away and it wouldn't click. Removed solid and it worked like a charm.

  • Problem Description

    Left click on object was not working until solid behavior was removed from the object. This is the only edit that was made to make this work. Not sure why.

    My action conditions

    on left button clicked on enemyUnit

    cursor is over enemyUnit

    playerUnit isTurn

    playerUnit isFiring

    not playerUnit hasFired

    player unit has line of site to enemyUnit.X, enemyUnit.Y

    Action

    playerUnit set mouseX to Mouse.X

    playerUnit set mouseY to Mouse.Y

    set destAngleX to enemyUnit.X

    set destAngleY to enemyUnit.Y

    set destAngleSet to true

    set rotateToDestAngle to true

    Debug readout on playerUnit

    isTurn 1

    isMoving 0

    mouseX 691.830985915493

    mouseY 58.59154929577465

    hasFired 0

    isFiring 1

    destAngleX 693.2717046230803

    rotateToDestAngle 1

    destAngleY 59.32356140793535

    destAngleSet 1

    Line of site for the playerUnit is 120px

    Steps to Reproduce Bug

    • Check to make sure your conditions are right.
    • If all else fails check to see what behaviors your using with mouse. Solid was the issue in this event.
    • Try removing the problem behavior if possible.

    Observed Result

    Clicking on the sprite would not register at all. Conditions were checked and double checked. Only removing solid fixed this issue.

    Expected Result

    Click on the sprite should set the variables mentioned above.

    Affected Browsers

    • Only tested in Firefox.

    Operating System

    Windows 8.

    Construct 2 Version ID

    R204.2

  • I've solved this. For some reason solid behavior was interfering with the mouse click. Not sure if this is a bug or not.

  • Hello,

    I've got a player sprite with a few variable on it, and an action I'd like fire if the user clicks on the enemyUnit. The problem is the left clicks are only registering if I click on the canvas. I'm not sure why this isn't working. Every single condition is met. Can someone tell me why it's not working? I really don't know. I've checked the other actions. I don't see where another action might be firing to mess this up. Any tips.

    Thank too. Just frustrated. There's unanswered posts, and not the first thing that's tripped me up, but might be my fault Thanks guys.

    My action conditions

    on left button clicked on enemyUnit

    cursor is over enemyUnit

    playerUnit isTurn

    playerUnit isFiring

    not playerUnit hasFired

    player unit has line of site to enemyUnit.X, enemyUnit.Y

    Action

    playerUnit set mouseX to Mouse.X

    playerUnit set mouseY to Mouse.Y

    set destAngleX to enemyUnit.X

    set destAngleY to enemyUnit.Y

    set destAngleSet to true

    set rotateToDestAngle to true

    Debug readout on playerUnit

    isTurn 1

    isMoving 0

    mouseX 691.830985915493

    mouseY 58.59154929577465

    hasFired 0

    isFiring 1

    destAngleX 693.2717046230803

    rotateToDestAngle 1

    destAngleY 59.32356140793535

    destAngleSet 1

    Line of site for the playerUnit is 120px

  • Sorry, I'm gonna bump this thread with a new event sheet. I really need someone to show me where my data is going wrong. I'm not understanding something. I'm trying to advance from simpler games to more difficult, but this player selection and movement stuff is confusing me. Someone please take a look at the image below and tell me what I am missing in understanding and flow of control.

    Objects on layout

    three playerUnits, a moveLocation

    playerUnit [isSelected = false, isMoving = false]

    moveLocation [uid = 0, isSelected = false]

    Basically for this example I would like to click a unit, move it to one of the moveLocations that pop up around it, and select another unit and move it.

    Bugs:

    Select a unit, the move tiles show up, select a different unit, the other units move tiles disappear, and the newly selected units move tiles show up. After the third unit is selected move tiles show up and the last units disappears. When I select any of the units again the last units move tiles disappear and the newly selected unit doesn't get move tiles.

    Second bug is I can't move. This happened when I added a Boolean condition, not sure which one. Before that the lerp was working but when I selected another unit as that one was moving it would stop moving. When I selected a move tile for the other unit that I just selected the other unit would move towards it too..

    Please help with understanding on how to order these programs. I can't seem to get out of simple stuff.

    Thanks,

    Jeremy.

  • Hello,

    I'm just trying to learn the tidbits it takes to make an RTS. Right now I'm just piecing together some bare bones elements. I've got the players and enemies. And a game engine, with one value. When a player clicks their unit some little squares show up showing where they can move. I've got an un-worked out lerp function, I'm not even sure what the lerp parameters are yet. Also when the player selects a unit the move boxes around the previously selected unit get destroyed.

    This is working pretty good, but there's a couple of issues. When the new units are selected the old units move boxes get destroyed as expected, but if the old units are selected again the move boxes don't get recreated.

    Thanks for your time.

  • To better suit the question. Is there an array of objects on the layout I can loop through, and access members and functions of those objects...

    for(key in objects)
    {
          if(key == 'name')  
         {
            if objects[key] == 'Cat'
           {
               // do this.
           }
    
       }
    }
    [/code:g49whr2a]
  • Hey,

    I'm wondering if someone can help me write a function. What I need to do is learn how to move objects that are already drawn on the layout. They would be placed there by the back end user. I think the function I'm writing would help a few people. It's really simple, and might be doable through events, but this one action plugin is cool. Maybe we could add to it for the other users. Likely one around, but what ever.

    Thanks,

    Jeremy.

JeremyBenson11's avatar

JeremyBenson11

Member since 24 Aug, 2015

None one is following JeremyBenson11 yet!

Trophy Case

  • 9-Year Club
  • Email Verified

Progress

10/44
How to earn trophies