I have two items, Object_Player and Object_Weapon. Object_Player's sprite can be three different sprites and Object_Weapon's sprite index should vary depending on Object_Player's sprite. For example, if Object_Player is set to the sprite Sprite_Hero1, the sprite index for Object_Weapon should be the first image in the sprite Sprite_Weapon. If Object_Player is set to the sprite Sprite_Hero2, the sprite index for Object_Weapon should be the second image in the sprite Sprite_Weapon.
This is the code which changes the index for Object_Weapon. It is in a create block for the Object_Weapon
if (Object_Player.image_index = Sprite_Hero1) sprite_index = 0
if (Object_Player.image_index = Sprite_Hero2) sprite_index = 1
if (Object_Player.image_index = Sprite_Hero3) sprite_index = 2
I think you're confused sprite_index
and image_index
. Try change:
if (Object_Player.sprite_index = Sprite_Hero1) image_index = 0
if (Object_Player.sprite_index = Sprite_Hero2) image_index = 1
if (Object_Player.sprite_index = Sprite_Hero3) image_index = 2