1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

GMS 2 Creating a Field of View

Discussion in 'Tutorials' started by Michael McMullen, Oct 3, 2019.

  1. Michael McMullen

    Michael McMullen Member

    Joined:
    Nov 4, 2017
    Posts:
    46
    GM Version: Gamemaker Studio 2
    Target Platform: N/A
    Download: N/A
    Links: N/A

    Summary:
    Using a combination of lengthdir_x/y we can have any object shoot a ray out of their position and check to see what is in front of them, or beside them. We can transform this into a field of view and determine if we find a player object, or solid wall.

    You can use this strategy to create walls that an enemy could not see through, or create a "window" where their vision could see through.

    Video:
     
  2. RichHopefulComposer

    RichHopefulComposer Member

    Joined:
    Jun 20, 2016
    Posts:
    1,388
    Nice tutorial. Thanks, MM!
     
    Michael McMullen likes this.
  3. johnwo

    johnwo Member

    Joined:
    Jun 20, 2016
    Posts:
    240
    Nice tutorial!

    The raycasting could be optimized by using collision_line. If a collision is found, simply use collision_line again, cutting the line in half every time, until the point of collision is found.
    Essentially a binary search; it would cut the worst case time down from O(n) to O(log(n)).
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice