GDevelop-extensions
GDevelop-extensions copied to clipboard
Trails
Description
This extension creates trails made out of particle emitters or shape painters from a point to another.
How to use the extension
Run the trail initialization action of a trail then run the trail creation action with the same name as the trail initialization action, to get some good results in things like a trail following a player, the trail initialization action should run before the object changes position, and then the trail creation action after the last changes of the player position in the frame, this may come with issues when using the core platformer character behavior since the player position is not changed in the same list as the trail actions.
If you want to make a trail for your cursor, you'll need to create an object that is always set to the cursor position, to do that, you need to run the trail initialization action and set it to the object's position, then after, change the position of that object to the cursor position and then run the trail creation action.
Checklist
- [X] I've followed all of the best practices.
- [X] I confirm that this extension can be integrated to this GitHub repository, distributed and MIT licensed.
- [X] I am aware that the extension may be updated by anyone, and do not need my explicit consent to do so.
What tier of review do you aim for your extension?
Community (Unreviewed)
Example file
Extension file
Thank you for submitting an extension.
Just to make sure, you don't want any review?
Thank you for submitting an extension.
Just to make sure, you don't want any review?
i guess a review would be good so, yeah
From a quick look I see that one object is created for each point. Did you ran into performance issues?
For the shape painter implementation
- a trail can be drawn in only one instance
- 2 circles + 1 line per segment may be a bit heavy and not be precised.
Did you consider drawing trapezoids instead?
From a quick look I see that one object is created for each point. Did you ran into performance issues?
For the shape painter implementation
- a trail can be drawn in only one instance
- 2 circles + 1 line per segment may be a bit heavy and not be precised.
Did you consider drawing trapezoids instead?
i did have some performance issues, but they were lower in comparison to the particle trail of the extension, and i might have to get documented on the creation of trapezoids
I've updated the extension so that the shape painter draws 1 line without the 2 circles.
i did have some performance issues, but they were lower in comparison to the particle trail of the extension
The issue could be that several particles are drawn on top of each other. Did you make sure that there is only one particle living at the same time per emitter?
i did have some performance issues, but they were lower in comparison to the particle trail of the extension
The issue could be that several particles are drawn on top of each other. Did you make sure that there is only one particle living at the same time per emitter?
yes, but it also depends on the minimum and maximum lifetime of the particles
i did have some performance issues, but they were lower in comparison to the particle trail of the extension
The issue could be that several particles are drawn on top of each other. Did you make sure that there is only one particle living at the same time per emitter?
yes, but it also depends on the minimum and maximum lifetime of the particles
the particle trail is supposed to be a fancy alternative to the shape trail for low resolution games
!update DrawTrails.zip
✅ Successfully updated the extension.
#1061 Improved version with better looks and optimization [Review]
I took a look to the new version, it's a nice improvement!
I have some suggestions:
- Events in extensions or example should never be collapsed.
- The Color Conversion extension has an expression to interpolate colors
RgbMean
(note that I should have fixed it to use HSL internally but we can always do it later). You can copy it in your extension and make it private.- JS events should avoid to use GDevelop variable and be alone in their own expression, condition or action.
-
lerp
can be used to simplify interpolation calculus - Properties and parameters can be used with just their names (like variables in the scene events)
- Private scene properties can be used as local variable to avoid too much
Object.Variable(TrailsGDExt.drawings[Object.VariableString(TrailsGDExt.drawingID)][Object.VariableString(TrailsGDExt.draw)]
which are hard to read.
What do you think about drawing only one trail per object instance?
- It would avoid one level of child variable.
- Parameters for style could be behavior properties.
- You could create one object of each style in you example.
Updated extension: Trails.zip
Updated example: TrailsExample.zip
-
Now a shape painter automatically draws a trail based of it's position, and the trail properties are now in the behavior properties tab (properties that can be changed via events).
-
The dot connection type has been improved.
-
Theorically, it's now more performant and easier to make trails.
❗ No updates found. Please check your file.
Thanks for the update!
I have more suggestions:
- Using the position of the object to get new trail points is a bit hacky
- The extension should follow how the shape painter usually works: actions that draw something on given coordinates. Thus, there should be an action to add a new point to the trail
- It makes formulas too complicated.
- There is a lot of variables for each point.
- Isn't the coordinates and time enough to draw the trail?
- For instance, why set
startColor
andendColor
when the properties can be used directly?
Took what i could get from the suggestions
Update v1.1.1: Trails.zip
- Reduced use of variables in the drawing of the trails
- Increased performance.
- Now the shape painter's layer time scale has an effect on trails.
- Now the trail can be drawn in a specified point with the "Draw trail at" action
- 1 point is referenced instead of 2.
- Draw trail automatically at painter's position can be toggled in events and behavior tab.
Example update: TrailsExample.zip
- Are you using the shape painter position to follow the logic of a particle emitter?
- Actually, that's interesting, it could make it easier to use the "sticker" extension to make the trail follow an object.
- Sorry about what I said last time.
- Let's start with only your automatic mode to keep it simple.
- I think it's not necessary to save the shape painter style as user won't draw on it themselves.
- I guess it's not necessary to store the start and the end as the start of one fragment is the end of the fragment next to it.
-
maxLength
andlength
are the same. Is it a typo?
- A hidden scene property can be used to iterate on the trail.
-
Object.Variable(TrailsGDExt.draws)
will be replaced byIndex
. - A scene property is shared by all trail but it's not an issue because this value can be forgotten from one time to another, it's not a state of the trail.
-
- Any variables that are part of the state and not in the Array should be replaced by private behavior properties (not scene properties this time)
- For instance:
removedPart
,totalDrawings
...
- For instance:
I'm excited to use this extension in my Geometry Dash clone. I'll test the latest version of this extension.
@Kennoir Wow, this extension is really neat! I'm definitely going to be putting this in my game.
https://github.com/GDevelopApp/GDevelop-extensions/assets/8879811/62209d7d-b86b-42a9-ac2f-4d8e09dcb4e8
Hello @Kennoir, do you need any assistance about my previous suggestions?
Hello @Kennoir, do you need any assistance about my previous suggestions?
Not at the moment, but i was offline since i took a break from GDev a while ago, i came back this week. I'm now going to work on the extension again.
Hello @Kennoir, do you need any assistance about my previous suggestions?
Well it was a lie, i need assistance because i lost the pace of what i was doing with this extension and i'm kinda lost in it's progress
I tried the demo on my old computer and 1 trail takes a third of a core. I'm sure it can be optimized but I guess that the shape painter won't be efficient enough for this.
The PIXI.SimpleRope
has a bit more features and seems very light. You can try Pixi examples here:
- https://pixijs.com/7.x/examples/advanced/mouse-trail
- https://pixijs.com/7.x/examples/mesh-and-shaders/textured-mesh-basic
I did a custom object with PIXI.SimpleRope
. You can try the demo on this PR:
- https://github.com/GDevelopApp/GDevelop-extensions/pull/1241
I credited you on the extension. Feel free to give it a review if you want.
I tried the demo on my old computer and 1 trail takes a third of a core. I'm sure it can be optimized but I guess that the shape painter won't be efficient enough for this.
The
PIXI.SimpleRope
has a bit more features and seems very light. You can try Pixi examples here:
- https://pixijs.com/7.x/examples/advanced/mouse-trail
- https://pixijs.com/7.x/examples/mesh-and-shaders/textured-mesh-basic
I did a custom object with
PIXI.SimpleRope
. You can try the demo on this PR:I credited you on the extension. Feel free to give it a review if you want.
That gaved the result i wanted but couldn't get because i don't know how to add libraries to GDevelop JS, i think we should use this instead of the shape painter