1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

[Solved]get number of in stances in an area along the same Y but across two X values

Discussion in 'Programming' started by Slothagami, Jun 5, 2019.

  1. Slothagami

    Slothagami Member

    Joined:
    May 30, 2019
    Posts:
    15
    Hey Everyone, so i went in WAAAAAAAAAAAAAAAAY over my head with this water physics calculations stuff, i need to find the number of water instances in an area (in the same y because they are in a grid) from the edges witch are set as LeftX and RightX, this is the last part of the equation that i need to make the water work and its just as difficult as the rest as i have never attemptedanything like this before.
    Image.png
    here is the attempt i have made, if it helps
    Code:
    var Count, PreviousInstance, CurrentInstance;
    Count = 0;
    PreviousInstance = noone;
    
    for(i = 0; i > WidthOfContainer; i++){
        CurrentInstance = instance_place(LeftX + i, y, oWater);
    
        if(CurrentInstance != noone and CurrentInstance != PreviousInstance){
            PreviousInstance = CurrentInstance;
            Count++;
        }
    }
    var FinalCount;
    FinalCount = Count;
    
    thanks in advance!
     
  2. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,968
    Just use "collision_line_list" along the line of instances and then use "ds_list_size" to find out how many are in the list. :)
     
  3. Slothagami

    Slothagami Member

    Joined:
    May 30, 2019
    Posts:
    15
    Thanks I didn't even think of that!
     

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