Hyper Trails - customizable trail effect

Hyper Trails was made when Mesh Component didn’t exist. It uses pixels from a texture as coordinates for vertices to make a trail. Actually, it should pass through models.

Try to enable depth testing and change trail.material's tag to “model”.

-- your render script
render.set_depth_mask(true)
render.enable_state(render.STATE_DEPTH_TEST)
render.draw(self.model_pred)
4 Likes

Thanks! I actually figured this out myself, works a treat.

4 Likes

A small update, v1.1.0:
Changelog:

  • Fix SPIR-V compilation (by @gmvbif)
  • Add auto_update property to the trail maker script. It’s useful if you want to be sure that a trail updates after a game object.
11 Likes

Does this work on Android and iOS ?

I get errors on my Android device:

WARNING:RESOURCE: Unable to create resource: /_generated_794b4e09.meshsetc: DDF_ERROR
WARNING:RESOURCE: Unable to create resource: /_generated_712aa04c.rigscenec: DDF_ERROR
WARNING:RESOURCE: Unable to create resource: /_generated_c8797aad.modelc: DDF_ERROR
WARNING:RESOURCE: Unable to create resource: /_generated_10116256.goc: DDF_ERROR
ERROR:GAMEOBJECT: Could not instantiate game object from prototype /_generated_10116256.goc.
WARNING:RESOURCE: Unable to create resource: /demo/demo_main.collectionc: FORMAT_ERROR

This likely indicates that some file is using an outdated format. We rarely do format breaking changes but it happens.

1 Like

Hello! it’s main branch? And what version defold?

Hyper Trails 1.2.0 and Defold 1.4.4 and android test device running Defold 1.4.0

Okay now its working once I updated my dev app to latest Defold version.

2 Likes

Is it possible to like add force cause my character is only moving in Y axis and the background is moving in X so it looks like player is moving to the right. But then the trail is also only moving up/down instead of trailing behind the player.

I am using this amazing extension for my game and I love it!!!

I have a question. For debug reason I implemented a slow motion effect by sending “set_time_step” to a collection with a factor 0f 0.1. When the slow motion is enabled the trails disappear, as if trail_maker.script is not taking into account the modified time step… this looks quite strange to me, probably I am missing something. Note also that if the time step factor is set to 0.0 then the trails do NOT disappear.

Thank you so much!

2 Likes

The trail maker script works simply: for every update, it saves the go position. It doesn’t use “dt” for most functions, except for auto length decreasing by time.
Your modified time step keeps calling update 60 times per second, so trail instantly disappears since the object is barely moving, right?

I would suggest increasing the “points_count” significantly and the “shrink_length_per_sec” option to adjust the trail length.

I understand your explanation, thank you @aglitchman.

Regarding your hint, just to check whether I get your point. When I enable slowmotion I modify “points_count” and “shrink_length_per_sec” via a script in order to compensate for the timestep factor. Are you suggesting this?

I will try. But a global timestep factor scaling all velocities would be super useful!

Hi! I’m trying to use this asset but I get this error after integrating–

ERROR:SCRIPT: hyper_trails/trail_maker.lua:198: attempt to index global ‘faststream’ (a nil value)
stack traceback:
hyper_trails/trail_maker.lua:198: in function init_buffers
hyper_trails/trail_maker.script:19: in function reset_trail
hyper_trails/trail_maker.script:26: in function <hyper_trails/trail_maker.script:25>

faststream is a dependency. Look in the readme (https://github.com/indiesoftby/defold-hyper-trails/blob/master/README.md) for usage instructions. I have not tried it; I assume it will work once you have set this up…

2 Likes

Yes I added both in my dependencies. I downloaded the git project and it works/builds fine so I’m definitely missing something when I integrated the asset to my own project.

Oh wait, it works now after rebooting Defold! :sweat_smile:

Remember that you need to do Project->Fetch Libraries to download dependencies you’ve added to your project. This is done automatically when you open a project.

4 Likes

I tested the idea myself on a test project and all you need to do is increase the parameters points count and fade tail alpha when slowing down time.

That is, if you slow down time by x10 times, then points count / fade tail alpha should be increased by x10 times. Because the number of update() script calls remains the same as it was, but the speed of your objects decreases by 10 times.

1 Like

Thank you so much! @aglitchman!

I will try to implement this in a “centralized” manner. Indeed I have a lot of game objects with trail around.

A question just out of curiosity. It seems to me that the extension hypertrail is just lua and the unique C++ code is in the other extension faststream. Is it so?

Thanks again!

Ciao!

1 Like

Yes! It was hugely upgraded by @KorolevSoftware some time ago and now it’s just Lua + faststream extension.

2 Likes