Joy's Recent Forum Activity

  • Allowing the enemy to attack when it's stopped moving (so when it reaches the imagepoints) does work, but it's not what I need. I really do think I need states and variables because the enemy will do different things depending on what the player does, and it could get complicated.

    ...guh, my game is dead in the water if I can't find a solution that allows this (and I won't be able to justify buying the Personal version either). If anyone has any ideas that could help, even if it means completely redoing movement, I'm all ears.

  • Thank you for looking at the code. The strange thing is that if I don't try to make states using variables and just put actions to be run when the enemy is in position, everything works (the enemy does attack when it gets in range). As soon as I set up the EnemyAction variables though, the actions that take place when the enemy gets into range do not work. I really don't think it has to do with precision only because it works otherwise, that's why I thought something was wrong with my code.

    I do something similar to call on player attacks using variables to trigger animations to play, and they all work too. Just wish I could figure out what's wrong with this one event...

    I guess I'll try adding an actual sprite for the enemy to try and overlap instead of imagepoints and see if that works. Thank you for the help so far!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Your commands do work (thank you), but the problem still isn't fixed. I'm sure I'm just missing something simple here, so here's an example of the code. Sorry to bother you guys with this!

  • Thank you for your help so far, I will try what you suggested and post again in a little while.

    My sprites are attached to invisible primitive shapes that act as bounding boxes, and in this particular case, the enemy sprite moves towards the player until it's bounding box overlaps one of the two imagepoints on either side of the player. It actually works very well, there's just a tiny animation issue that I'll try to fix later. Got to fix this problem first.

  • I changed the variables to numeric and I have the same results. I think the problem occurs when the enemy reaches one of the two Player's imagepoints (Player_Target.ImagePointX(1) | Player_Target.ImagePointX(2).)

    Could you tell me how you might add an action to determine when the enemy has reached an imagepoint and switch the instance variable from 0 to 1 (or whatever)? Whatever I'm doing, it's not right. Very sorry I can't post a capx now, I'm making this for a friend and I'm not supposed to share it yet. If we can't figure it out though, I'll try to make a dummy one and at least post screenshots of the code.

  • Thanks, but they all seem to be correct. No quotes in the default EnemyAction variable and all of the ones that are called upon have the quotes (or I get the error message saying it's an unknown expression).

    (oh you edited your post, thanks). I did try that once, but I'll do it again and post again shortly.

  • I worked on this all day and I absolutely cannot figure out what is wrong. Probably something really simple, but I'm just not seeing it.

    I have an enemy that checks to see if it's touching one of two imagepoints on a player object =

    Enemybbox (inverted) X = Player_Target.ImagePointX(1) | Player_Target.ImagePointX(2)

    If it does not (meaning the above script is true), a instance variable on Enemybbox called "EnemyAction" is set to a text value of "CHASE". This causes the enemy to move towards either of the Player's two imagepoints. That all works fine.

    However, when the enemy reaches one of the player's imagepoints, I want to switch the instance variable from "CHASE" to "FIGHT", stop moving, and start following a new set of commands listed under an Enemybbox EnemyAction="FIGHT" action. The enemy does stop (because it reaches the imagepoint), but I can't get the variable to change. Even when it's stopped and when I have actions that tell the variable to switch to "FIGHT" once it's reached the imagepoint, in the debugger, it still shows the EnemyAction value as "CHASE".

    Inverting the above script does not work (example below), and I've also tried this with global variables and it didn't work either.

    Enemybbox X = Player_Target.ImagePointX(1) | Player_Target.ImagePointX(2) Set EnemyAction to "FIGHT"

    I really want to use variables because I need to have different states for the enemy (chase, fight, hit, dead, evade, etc). Any help would be greatly appreciated!

  • I checked a lot of tutorials and all the ones I could find regarding analog movement talk about a virtual analog stick for tablets and such. I'm trying to set up analog movement based on how far you move an Xbox 360 pad's left stick.

    Could someone tell me if there's a more efficient way of doing it than in this picture? That's working for me so far, but maybe I'm overlooking an easier way.

    Thanks in advance!

  • That does make sense, thanks very much. I was just starting to understand it when you replied, and you confirmed what I wasn't sure about.

    Sorry to bother you and thanks again!

    edit: funny, I came across that same thread that you linked to when I first encountered this problem, but I had no idea what that guy was having problems with. Seems I'm not the first one you've helped understand this.

  • Thank you again Minor, I see that it does work. Could you explain in a little more detail how this part of your code works though?

    Set distance to distance(attack_detect.X, attack_detect.Y, attack_detect.X, enemy_hitbox.Y)

    I assume the first two entries retrieve the X and Y coordinates of the player's attack box, but why do you use another X command for the attack box with the Y for the enemy hitbox? I'm not questioning that your method works, I just don't quite understand exactly what's happening with it.

    Thanks for your time so far!

    edit: Oh, I see that function does require x1, y1, x2, y2, sorry. If you have time though, could you still explain what measurements are taking place? I'm more of a graphics person than a math person.

  • It's working, thanks again! I do have one other question though; if the enemy hitbox is moving vertically at all (i.e. the enemy is moving), the check for the Y value of the player or the player's attack box may not be accurate. Could you tell me how, if it's possible, to actually check the Y value of the location on the enemy hitbox where the attack box overlapped it, and not the Y coordinate of the screen? The attack box can be 1 pixel in order to get a precise value.

    Thanks!

  • Thank you both very much! It is really late here, but I will follow your advice and let you know if I get it fixed. Much appreciated!

Joy's avatar

Joy

Member since 17 Jun, 2014

None one is following Joy yet!

Trophy Case

  • 10-Year Club
  • Email Verified

Progress

11/44
How to earn trophies