Questions: UV Coords, Components manipulating

Got some questions:

  1. Can I manipulate with UV coords of texture? To create scroll effect with just one sprite and GO?

  2. I want to stay in-game enemies corpses and bullets shells. For enemies: how I can create it without troubles with factories (max_capacity)? And after enemy die, i want to remove scripts for performance things. For bullets shells: it should be like particles with little physics, but stay in-game. What the best way to do it?

  3. I have a some of guns in my game.And they have parameters (+ differents sounds (components), etc.). Can I generate GO in game? The way to do it in one GO is not perfect (will be a lot of components). Seeking way to do it real-time.

Thanks :slight_smile:

  1. I think that’s possible - I don’t know for sure though.
  2. Actually, I think you should use factories for this, since that’s what they are for. Create a GO with your enemy script and sprite attached and save it as a file. Create a factory to be able to spawn that GO. Use the factory to spawn when needed, or delete when enemy dead. When you delete an instance of a factory spawn gameobject, all its attached resources (sprites, scripts, etc) should be removed too…
  3. Create one gameobject for this type of wappon (as a protopype so to say), and create instances of it at runtime.
  1. Dont fully understand you. You suggest do two factories (enemy and enemy_corpses) and use it? I think there is factory max_instances problem. But I will try it anyway, thanks.
  2. Every type of weapon have different components (sounds, particles), so I want to generate the prefab (presets of components)

Thanks you for your answers :slight_smile:

Hello @Insality

It will be useful to access sprite UV’s. But i couldn’t find a way to access that option.
Instead my background’s follows character , using character speed and a reduction variable(changes by distance of background). So the player is fast and background is slow, after player passed a background, background changes its position. Here a scene setup.

  • You see there is 3 backgrounds with sensor colliders.

Cons :

  • jitter between background objects,
  • 3 game object with update function.
    Pros :
  • jobs done.

Its good to know if anyone handles this with an optimum solution.

Best Regards,

Yes. Create two gameobjects (enemy and enemy_corpses). Treat each of them as a prefab. Create two factories (enemy_spawner and enemy_corpses_spawner) and assign the gameobjects (enemy and enemy_corpses) to them. Then you can use the the factories to spawn those gameobjects at runtime.

# Edit: I found this tutorial, that suggests to create collections (which would be your prefabs enemy and enemy_corpses). If you go this route, then you’ll need to use collection factories instead of regular factories.

You can do it either way I think.

@Insality Question (1) -> Do you mean parallax scrolling? If so, and you need to do it with only one sprite, I’d imagine you can use a custom shader to make it work.

1 Like

Just use a simple scroller shader for the uv

Hello @ThunderZ ,

Do you have sample shader for defold , for scroller.

Best Regards,

I’m in holidays for 2 weeks just have some web on my phone (poor connection) but you can start reading this : http://www.defold.com/manuals/material/

Shader in defold isn’t too complicated to setup and you will fond uv scrool shader easily with Google :wink:

If you’re block i’ll help you back to holidays

1 Like

I’m the very bad at shaders, and now trying do it, here the result.

It’s need the atlas with single image to correct wrapping, right?

And i didn’t know how to set correctly wrap UV, so it’s look ugly :smiley:

4 Likes

No nice work.

Did you set wrap mode to repeat ?

WRAP_MODE_REPEAT
Texture data outside the range [0,1] will repeat

1 Like

Yea! Im tried to do it, but seems I have set it to wrong constant name
Now I set it to parameter “DIFFUSE_TEXTURE” and all works well. The sprite wrap correctly.

2 Likes

Nice to see that is working :grin:

1 Like