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

GM:S 1.4 Simultaneous instance create

Discussion in 'Programming' started by jf_knight, Dec 30, 2018.

  1. jf_knight

    jf_knight Member

    Joined:
    Dec 23, 2016
    Posts:
    86
    I'm trying to implement a hit-scan shotgun. Every instance...
    Code:
    instance_create(x+lengthdir_x(length,direction ),y+lengthdir_y(length,direction ),projectile)
    
    ...creates one "hit-scan line". I would like to use 5 or 6 at once, however an instance is created one after another and not at the same time. What can I do so that 5 instances happen at the same time? I've tried using an "AND" after each line but to no avail.


    I'm not too familiar with alarms, but is it possible to have a millisecond pause and wait until all the hit-scans are "loaded" and then have them created at once?
     
  2. HayManMarc

    HayManMarc Member

    Joined:
    Jun 21, 2016
    Posts:
    936
    Code:
    repeat(5)
      {
         instance_create(x+lengthdir_x(length,direction ),y+lengthdir_y(length,direction ),projectile);
       }
    
    Note that each of the 5 instances will be placed in the exact same position.
     
  3. jf_knight

    jf_knight Member

    Joined:
    Dec 23, 2016
    Posts:
    86
    I'm one step closer! You're right, they do all align. There is also a small dip in fps when I press the "shoot" button rapidly signifying that the collision detection is registering.
    Now if only I can add some random number variation to the "direction " property...
     
  4. IndianaBones

    IndianaBones Member

    Joined:
    Jul 5, 2016
    Posts:
    2,297
    There's a function for that, called random(), also random_range() and if you just want integers, irandom() and irandom_range()
     

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