Why enemy character is avoid my player character when my character is overlapping enemy character ?

0 favourites
From the Asset Store
Players follower. use it for anything which follows the player
  • Why my enemy character is avoid my player character when my character is overlapping enemy character?

    drive.google.com/file/d/1R0u7l5qFBzJUAHq2leqFlrsT-9UweHp_/view

  • If you mean, why is it moving to the right, your events say to move to the right if X is greater than player.

  • As lionz said, you're checking whether your enemy is either left or right of a very specific coordinate (the player's X). Your enemy will still move even when they're overlapping, because you've told them to keep moving at all times, either left or right

    If you want enemies to do nothing when they're overlapping, you have to change when you tell them to stop moving.

    Try using the edges of the player's sprite instead of X. You can use the BBox property (bounding box) instead. And add an else statement to make it a little neater.

    If Enemy.X is greater than Char.BBoxRight

    ...Enemy simulate moving left

    Else

    If Enemy.X is less than Char.BBoxLeft

    ...Enemy simulate moving right

  • As lionz said, you're checking whether your enemy is either left or right of a very specific coordinate (the player's X). Your enemy will still move even when they're overlapping, because you've told them to keep moving at all times, either left or right

    If you want enemies to do nothing when they're overlapping, you have to change when you tell them to stop moving.

    Try using the edges of the player's sprite instead of X. You can use the BBox property (bounding box) instead. And add an else statement to make it a little neater.

    If Enemy.X is greater than Char.BBoxRight

    ...Enemy simulate moving left

    Else

    If Enemy.X is less than Char.BBoxLeft

    ...Enemy simulate moving right

    How to make a BBox property?

  • It's a built-in property of the Sprite object.

    Sprite.BBoxLeft, for example, returns the X value of the left edge of your sprite.

    Definitely look up the Sprite object in the Construct manual, it'll give you more info (I highly recommend reading the manual whenever you can, it's really great)

  • It's a built-in property of the Sprite object.

    Sprite.BBoxLeft, for example, returns the X value of the left edge of your sprite.

    Definitely look up the Sprite object in the Construct manual, it'll give you more info (I highly recommend reading the manual whenever you can, it's really great)

    So I make a BBox is make to char instance variable or I make another new sprite object?

  • Try something like this, just to see what BBox is like. It uses char.BBoxLeft and char.BBoxRight, rather than char.X, as the point of comparison. There's also a Margin number if you want to customize the distance even more. And it separates the mirror from the follow movement.

  • Try something like this, just to see what BBox is like. It uses char.BBoxLeft and char.BBoxRight, rather than char.X, as the point of comparison. There's also a Margin number if you want to customize the distance even more. And it separates the mirror from the follow movement.

    And then must I remove line of sight or still using line of sight?

  • I'm not sure how you're using LOS, or how it affects your enemy movement. I would just keep experimenting until it's behaving the way you'd like it to!

  • I'm not sure how you're using LOS, or how it affects your enemy movement. I would just keep experimenting until it's behaving the way you'd like it to!

    How I click greater or equal and less or equal in keyboard?

  • That's the kind of thing you can get from Google faster than a forum. Just search for your question and you'll get the answer!

  • Try something like this, just to see what BBox is like. It uses char.BBoxLeft and char.BBoxRight, rather than char.X, as the point of comparison. There's also a Margin number if you want to customize the distance even more. And it separates the mirror from the follow movement.

    char.BBoxRight + Margin ≤ luBuEnemy.X ≤ LayoutWidth is use for evaluate expression or is number NaN or Object UID exists?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Try something like this, just to see what BBox is like. It uses char.BBoxLeft and char.BBoxRight, rather than char.X, as the point of comparison. There's also a Margin number if you want to customize the distance even more. And it separates the mirror from the follow movement.

    What event in system should I use in char.BBoxRight + Margin ≤ luBuEnemy.X ≤ LayoutWidth ?

  • That's the system action "is between values"

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