How do I set the line-of-sight behavior to the bounding box or something else?

0 favourites
  • 4 posts
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • Hi all, question, I just added the line-of-sight behavior to my main character in a point-and-click adventure to check the distance between him and an object to pick-up. However, much like my previous method to check the distance (object.x, object.y compared to player.x, player.Y), both instances take the anchor point of my sprite as the go-to for the distance check. I actually want the bounding box of my sprite to be the reference point. Is this possible at all?

    Thank you in advance.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you are referring to the source object then it will be from the origin image point by default in the centre so I don't see how that can be changed, if you are using that object then you can pin another sprite to the front of it and give that the line of sight.

    If you are referring to target object you can use line of sight to position object x,y minus half the width of the object, the only problem with this is you would need to alter logic depending on if its on the left or right side of the player, or above and below if that's possible. My approach is to add another image point to the front of the target object on the bounding box, you can then use line of sight to position object.imagepointx(1), object.imagepointy(1) which targets that new imagepoint and not the origin in the middle.

  • Thanks, I will try it out with a single image point and otherwise perhaps with if/else statements for multiple image points. The thing is that visually the objects might differ by being i.e. somewhere on the floor or just above the player's head, and while visually coming near the object my character will never come within say a 150 pixels in coded range because of this difference. But I will try some stuff out by adding image points.

  • If you are referring to the source object then it will be from the origin image point by default in the centre so I don't see how that can be changed, if you are using that object then you can pin another sprite to the front of it and give that the line of sight.

    And to clarify this, I got my origin point at the bottom to avoid weird rotations.

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