GDevelop-extensions icon indicating copy to clipboard operation
GDevelop-extensions copied to clipboard

Trails

Open github-actions[bot] opened this issue 1 year ago • 24 comments

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

KTrails.zip

Extension file

DrawTrails.zip

github-actions[bot] avatar Apr 09 '23 20:04 github-actions[bot]

Thank you for submitting an extension.

Just to make sure, you don't want any review?

D8H avatar Apr 09 '23 21:04 D8H

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

Kennoir avatar Apr 09 '23 23:04 Kennoir

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?

Trail

D8H avatar Apr 14 '23 08:04 D8H

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?

Trail

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

Kennoir avatar Apr 14 '23 20:04 Kennoir

I've updated the extension so that the shape painter draws 1 line without the 2 circles.

Kennoir avatar Apr 14 '23 22:04 Kennoir

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?

D8H avatar Apr 14 '23 23:04 D8H

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

Kennoir avatar Apr 14 '23 23:04 Kennoir

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

Kennoir avatar Apr 14 '23 23:04 Kennoir

!update DrawTrails.zip

Kennoir avatar Sep 28 '23 03:09 Kennoir

✅ Successfully updated the extension.

github-actions[bot] avatar Sep 28 '23 03:09 github-actions[bot]

#1061 Improved version with better looks and optimization [Review]

Kennoir avatar Oct 20 '23 20:10 Kennoir

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.

D8H avatar Oct 20 '23 23:10 D8H

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.

Kennoir avatar Oct 28 '23 00:10 Kennoir

❗ No updates found. Please check your file.

github-actions[bot] avatar Oct 28 '23 00:10 github-actions[bot]

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 and endColor when the properties can be used directly? image

D8H avatar Oct 28 '23 11:10 D8H

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

Kennoir avatar Oct 29 '23 00:10 Kennoir

  • 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 and length are the same. Is it a typo?

image

  • A hidden scene property can be used to iterate on the trail.
    • Object.Variable(TrailsGDExt.draws) will be replaced by Index.
    • 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.

image

  • 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...

D8H avatar Oct 29 '23 13:10 D8H

I'm excited to use this extension in my Geometry Dash clone. I'll test the latest version of this extension.

tristanbob avatar Dec 27 '23 14:12 tristanbob

@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

tristanbob avatar Dec 27 '23 19:12 tristanbob

Hello @Kennoir, do you need any assistance about my previous suggestions?

D8H avatar Jan 10 '24 09:01 D8H

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.

Kennoir avatar Feb 20 '24 15:02 Kennoir

Hello @Kennoir, do you need any assistance about my previous suggestions?

Trails.json

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

Kennoir avatar Mar 30 '24 19:03 Kennoir

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.

D8H avatar Apr 01 '24 22:04 D8H

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

Kennoir avatar Apr 05 '24 14:04 Kennoir