Independent Sight Engine Help

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • So, I'm attempting to make an engine where enemies are able to detect the proximity of a player without the need for a secondary object. The items I have in frame are "Player" (and Eight Directions Object), and "Enemy" (A bouncing Ball Object)
    Enemy has the following attributes:
    A- XPos (Enemies X Position) - 0
    B- YPos (Enemies Y Position) - 0
    C- XDet (Players X Position) - 0
    D- YDet (Players Y Position) - 0
    E- Sight (Range of sight) - 80

    The code I have is:

    >Always: Set XPos(Enemy) to Abs(X("Enemy))
    >Always: Set YPos(Enemy) to Abs(Y("Enemy))
    >Always: Set XDet(Enemy) to Abs(X("Player))
    >Always: Set YDet(Enemy) to Abs(Y("Player))

    >When Enemy's (Abs(XPos("Enemy")-XDet("Enemy")) <= Sight("Enemy")
    >When Enemy's (Abs(YPos("Enemy")-YDet("Enemy")) <= Sight("Enemy"): Start Enemy

    The goal is to make it so when Player is within 80 pixels of Enemy, the enemy will start. I have counters that show both the XPos-XDet and YPos-YDet in-game, showing that the equation isn't the problem, but it still won't respond to the "Start" command unless I do some arbitrary random movement. Please help.

  • SQR is short for square root. Don't type in square root, though, as that won't work in the expression editor of MMF2. Instead, type in "SQR".

    My Please login to see this link. (which I actually use), my Please login to see this link. (which I mostly don't use), and my Please login to see this link. (which I don't use anymore pretty much at all really). If there are awards for "'highest number of long forum posts", then I'd have probably won at least 1 by now. XD

  • Sqr is square root

    ...
    For example, if you write

    Sqr( 9 )

    in the expression editor, MMF2 will calculate the square root of the number 9 ( which is 3 )

    ...
    If you dont like equations like this, the AdvancedDirection Object can easily calculate the distance between 2 Objects for you.

    How can i change username and display name?
    Please login to see this link.

  • + Always
    -> Enemy: Set DistanceToPlayer to Sqr((X("Enemy")-X("Player")) pow 2+(Y("Enemy")-Y("Player")) pow 2)

    + Enemy: DistanceToPlayer < 80
    -> Enemy: Start


    Alternatively,

    + Enemy: VisionRange > Sqr((X("Enemy")-X("Player")) pow 2+(Y("Enemy")-Y("Player")) pow 2)
    -> Enemy: Start


    Just don't try and use "compare two general values", because that won't work.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!