GM:S 1.4 [SOLVED] Having gun in hand!

Discussion in 'Programming' started by santeri kalliomaki, Feb 19, 2018.

  1. santeri kalliomaki

    santeri kalliomaki Member

    Joined:
    Feb 11, 2018
    Posts:
    13
    I'm making ragdoll game and guns in ground are visible but if i pick them up they can't be seen... o_O


    code in object player step event:

    with Hand_R{
    if (mouse_check_button_pressed(mb_right)) {
    if (gun == -1) {
    with (instance_place(x, y, oGunPickup)) {
    other.gun = image_index;
    instance_destroy();
    }
    } else {
    var oldGun = gun;

    // Pickup new gun
    if (instance_place(x, y, oGunPickup)) {
    with (instance_place(x, y, oGunPickup)) {
    other.gun = image_index;
    instance_destroy();
    }
    } else {
    // no gun
    gun = -1;
    }

    // Throw old gun
    with (instance_create(x, y, oGunPickup)) {
    image_index = oldGun;
    direction = point_direction(other.x, other.y, mouse_x, mouse_y);
    speed = 14;



    }
    }
    }}


    code in player create event:
    with Hand_R{
    gun = 0;}

    code in gun object create event:

    image_index = choose(0, 1); (it has 2 different sprites)
    image_speed = 0;
    image_angle = random(360);
     
  2. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,899
    Where are you drawing the gun once the player picks it up?
     
  3. santeri kalliomaki

    santeri kalliomaki Member

    Joined:
    Feb 11, 2018
    Posts:
    13
    Oh sorry im such an idiot :D thanks
     
  4. santeri kalliomaki

    santeri kalliomaki Member

    Joined:
    Feb 11, 2018
    Posts:
    13
    Do you know how can I get it to follow the hand none of my codes work.
     
  5. hogwater

    hogwater Member

    Joined:
    Jun 22, 2017
    Posts:
    635
    I don't know about this avatar man.
     
  6. santeri kalliomaki

    santeri kalliomaki Member

    Joined:
    Feb 11, 2018
    Posts:
    13
    9gag nazi
     

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