User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11

Thread: Line of sight

  1. #1
    No Products Registered

    Join Date
    Jul 2014
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Line of sight

    Is there a way to determine if there is a clear line of sight between two objects?

    For instance, the enemy only shoots if there's nothing in-between it and the player.

  2. #2
    Clicker Fusion 2.5Android Export Module

    Join Date
    Feb 2014
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try shooting an invisible object which gets destroy when hitting anything but the player. If it reaches the player there's a line of sight.

  3. #3
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export Module

    Join Date
    Dec 2013
    Posts
    139
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please use the search functions as there are many threads and also examples available.

    Extension:

    http://www.triplezap.com/extensions/

    Example:

    http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=194709

  4. #4
    Clicker Fusion 2.5Fusion 2.5+ DLCAndroid Export ModuleiOS Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    blurymind's Avatar
    Join Date
    Feb 2014
    Location
    Huddersfield, United Kingdom
    Posts
    496
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    you can create an active object and call it line. Make the object track the enemy and at the same time stretch to the player. This can be done with an expression on the line of sight object:

    set position to enemy

    set X scale:
    0.0 + Sqr(( ( X( "player" ) - X( "Enemy" ) ) pow 2 ) + ( ( Y( "player" ) - Y( "Enemy" ) ) pow 2 ) ) / 10.0

    set angle:
    ATan2(Y( "Enemy" ) - Y( "player" ), X( "player" ) - X( "Enemy" ) )

    If the stretching line of sight object is overlapping a background wall, then player is not visible
    if stretching line of sight object width > X, then player is too far to be seen.

    Hope this helps.

    There was an example file burried somewhere, but I forgot where.

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export Module
    tompa's Avatar
    Join Date
    Nov 2011
    Location
    Uppsala, Sweden
    Posts
    358
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I like the idea blurymind, thanks for bringing it up.

  6. #6
    No Products Registered

    Join Date
    Jul 2014
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by blurymind View Post
    you can create an active object and call it line. Make the object track the enemy and at the same time stretch to the player. This can be done with an expression on the line of sight object:

    set position to enemy

    set X scale:
    0.0 + Sqr(( ( X( "player" ) - X( "Enemy" ) ) pow 2 ) + ( ( Y( "player" ) - Y( "Enemy" ) ) pow 2 ) ) / 10.0

    set angle:
    ATan2(Y( "Enemy" ) - Y( "player" ), X( "player" ) - X( "Enemy" ) )

    If the stretching line of sight object is overlapping a background wall, then player is not visible
    if stretching line of sight object width > X, then player is too far to be seen.

    Hope this helps.

    There was an example file burried somewhere, but I forgot where.
    I don't understand what sqr or pow does, but I'll try it.

  7. #7
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Ryan's Avatar
    Join Date
    Nov 2008
    Location
    Australia
    Posts
    1,275
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sqr is Square Root and Pow is to the Power of
    They're most often used in triginometry to find the length of the hypotenuse in a triangle, it's commonly known as the distance formula.

    a^2 + b^2 = c^2
    rearrange to find c
    c = sqr(a^2 + b^2)

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUnicode Add-onInstall Creator

    Join Date
    Jul 2006
    Posts
    1,018
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can replace this formula with an inbuilt expression from the Special object:

    Distance(>X of first point<, >Y of first point<, >X of second point<, >Y of second point< )

    (Special > Distance and Angle > Distance between two points)

    Here is a quick example: Attachment 13916

  9. #9
    No Products Registered

    Join Date
    Jul 2014
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Gustav
    You can replace this formula with an inbuilt expression from the Special object:

    Distance(>X of first point<, >Y of first point<, >X of second point<, >Y of second point< )

    (Special > Distance and Angle > Distance between two points)

    Here is a quick example: line_of_sight.mfa
    Doesn't that just measure distance though?

  10. #10
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Ryan's Avatar
    Join Date
    Nov 2008
    Location
    Australia
    Posts
    1,275
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Which is what you're trying to achieve, set the X scale of the object to the distance between the two objects

    If distance is this: A_________B
    Don't you want your object to do this: AOOOOOOOOOB

    The rotation ensures it's always looking in the direction of the enemy, and if you always set it's x&y coordinates to the player it will follow the player.

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Line of sight
    By JosephFTaylor in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 15th June 2012, 05:12 PM
  2. Line of Sight
    By Panchos in forum Multimedia Fusion 2 - Technical Support
    Replies: 14
    Last Post: 29th August 2010, 11:36 AM
  3. Line of Sight
    By Uzalu in forum Extension Development
    Replies: 1
    Last Post: 5th December 2009, 10:52 PM
  4. Line of sight
    By Beginier in forum File Archive
    Replies: 4
    Last Post: 24th June 2009, 05:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •