Gameobject instance sprite problem (SOLVED)

Hello,

I have a weapon.go and it includes collisionobject, sprite and script. For each weapon I create one instance in the collection and change its properties. I can change script properties and it doesn’t effect any other instances. But when I change default animation of the sprite. It effects all instances. So I have to change animation in the initializer function. Are there any other solutions for this?

Thanks :slight_smile:

1 Like

You could declare a script property (using go.property()) that will be exposed on the script component and use that to set an animation when the weapon is created:

	--weapon.script
	go.property("anim", hash("defaultanim")

	function init(self)
		msg.post("#mysprite", "play_animation", { id = self.anim })
	end
2 Likes

Thanks :slight_smile: .

I created a collection for weapons and when I need to use a weapon I basically copy and paste it to the scene. And I get datas from a json file and initialize properties. This solved my problem :slight_smile: