GML 1.4.9999 selecting players ship

woods

Member
i am having an issue with getting my player to select one of many ships properly.

i have 10 obj_player_select_P1 placed in the starting room. with creation code image speed = 0 and image index = 0 thru 9 (one for each instance)
the idea is to move my player over the object in the starting room to select the particular ship.

obj_P1 step event
Code:
/// select ship

if (place_meeting(x,y,obj_ship_select_P1))   
{
    if (other.image_index = 0)
    {
        sprite_index = spr_ship_0;
        turn_spd = 3;
        thrust = 0.03;
        spd = 3;
    }
}


if (place_meeting(x,y,obj_ship_select_P1))
{
    if (other.image_index = 1)
    {
        sprite_index = spr_ship_1;
        turn_spd = 5;
        thrust = 0.05;
        spd = 5;
    }
}
the above code is only for the first 2 ships.. [0] and [1] ... i figured get it working to swap between 2 before i try 10 ;o)

with the ship_select object, i have some debug text showing the image index above each ship..
Code:
draw_text_transformed(x,y-64, "image index: " + string(image_index),2,2,0);
i have 0 thru 9 on each as expected


ship.jpg

the issue i am having is the player will change to the first ship only, no matter which one it touches.
looking for some guidance, if you would be so kind
 
Last edited:

Nidoking

Member
You can't use "other" that way. other only applies in a with or a collision event. instance_place will give you the ID of the colliding object, where place_meeting only gives true or false.
 

woods

Member
awesome.. thanks for pointing in the right direction

Code:
/// select ship

var inst;
inst = instance_place(x, y, obj_ship_select_P1);
if inst != noone
   
    if (inst.image_index = 0)
    {
        sprite_index = spr_ship_0;
        turn_spd = 5;
        thrust = 0.05;
        spd = 5;
    }

else
    
    if (inst.image_index = 1)
    {
        sprite_index = spr_ship_1;
        turn_spd = 5;
        thrust = 0.05;
        spd = 5;
    }

else
  
    if (inst.image_index = 2)
    {
        sprite_index = spr_ship_2;
        turn_spd = 5;
        thrust = 0.05;
        spd = 5;
    }

else
  
    if (inst.image_index = 3)
    {
        sprite_index = spr_ship_3;
        turn_spd = 5;
        thrust = 0.05;
        spd = 5;
    }

else
  
    if (inst.image_index = 4)
    {
        sprite_index = spr_ship_4;
        turn_spd = 5;
        thrust = 0.05;
        spd = 5;
    }

else
  
    if (inst.image_index = 5)
    {
        sprite_index = spr_ship_5;
        turn_spd = 5;
        thrust = 0.05;
        spd = 5;
    }

else
  
    if (inst.image_index = 6)
    {
        sprite_index = spr_ship_6;
        turn_spd = 5;
        thrust = 0.05;
        spd = 5;
    }
    
else

    if (inst.image_index = 7)
    {
        sprite_index = spr_ship_7;
        turn_spd = 5;
        thrust = 0.05;
        spd = 5;
    }


ill report back when i run into more issues... issues always happen ;o)

i think next step is working out balance issues for stats
 
Top