Joy's Forum Posts

  • 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!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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!

  • This may be hard to explain and I'm sorry I can't share my current .capx, but hopefully someone will understand.

    I have a very large sprite (an enemy) that's attached to a simple, very long vertical rectangle acting as it's hitbox. When the player attacks it (by spawning an square 'attack box' that overlaps anywhere on the enemy rectangle hitbox), the enemy plays a hit animation - all of that is working fine. What I'd like to know is how I can have the player's attack box check the y coordinate when it overlaps the enemy rectangle hitbox, and have the enemy play a different hit animation if it's over or under a certain value.

    Basically I'm trying to fake a sprite having multiple collision boxes by having it play different animations based on where it is attacked on the long vertical hitbox. I've got all my animations set up based on global variables, so I do understand that much. What I don't know is how to set up the events and actions for the collision to check the Y coordinate of the enemy's box and send a value to a new variable that will trigger an animation based on how high the Y value is.

    Any advice is appreciated! Thank you for your time.