GMS 2 Rotating Sprites based off Movement direction

Discussion in 'Programming' started by BirdsGoFly, Dec 7, 2018.

  1. BirdsGoFly

    BirdsGoFly Member

    Joined:
    Dec 5, 2018
    Posts:
    5
    I have a gun scripted. However, whenever I fire, the bullet sprite remains straight. I've tried fixing this by using:

    in Bullet "Create" event:
    Dir = irandom(10);
    image_angle = Dir;
    motion_set(5 - Dir, 100);

    Wherever I put image_angle or word it, it doesn't seem to work. Any suggestions?
     
  2. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    5,647
    irandom(10) is nothing for an image_angle. It's rotating, you're just not noticing it. Probably because your speed is so high...

    Are you just creating the bullet and then moving on, or is the gun changing any of the bullet's variables after it creates it?
     
  3. BirdsGoFly

    BirdsGoFly Member

    Joined:
    Dec 5, 2018
    Posts:
    5
    The bullet after creation is not altered by the gun to my knowledge. I also set Dir to be 90 without the irandom, and set the speed to 5 to see it's effects. The bullet remains straight.
    If you need it, here's the place where the bullet gets called:

    //On Fire
    var Projectiles = 4 + irandom(1)
    for(i = Projectiles;i >= 0; i -= 1 ) { //shotgun
    instance_create_layer(x,y,"Instances",OBJ_SmallProjectile); //Create Bullet
    }
     
  4. BirdsGoFly

    BirdsGoFly Member

    Joined:
    Dec 5, 2018
    Posts:
    5
    Nevermind, I was able to fix it.
     

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