How can we show a sprite using a mesh component that supports transparency?

I want to show png image using mesh. it showing by following steps, but behind the sprite that is a png with transparency, is black.
I created a game object and added a mesh to it. then set below buffer as vertices. and then set my png image as tex0.
now it showing but without support transparency and behind of it is black. how can I fix that?


softbody.buffer.zip (374 Bytes)

1 Like

Here is a simple project example that works.
Maybe valuable for someone.

We need to adjust the render script.
I don’t know what exactly, but this is working.

MeshSpriteTest.zip (294.6 KB)

How can I change the tex0 property and replace it with another PNG image at runtime by script?

You should be able to use go.set() and a texture property:

go.property("my_texture", resource.texture("/texture.png"))

function init(self)
    go.set("#mesh", "tex0", self.my_texture)
end
2 Likes

Thanks, I didn’t think it would be this simple!
Although, I should have used “texture0” instead of “tex0”.

go.set("#mesh", "texture0", self.my_texture)

Why can’t we do that just?:

go.set("#mesh", "texture0", resource.texture("/texture.png"))

Showing this error:
attempt to call field ‘texture’ (a nil value)

Another question is, can I use Atlas here?
Or does using Atlas here in mesh make no sense?

The go.property("foo", resource.texture("my.png")) is a compile time declaration of a resource and is used by our build system to include the references resource into the resource system and game archive when the game is built.

2 Likes