Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trails #856

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Trails #856

wants to merge 2 commits into from

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Apr 9, 2023

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

  • I've followed all of the best practices.
  • I confirm that this extension can be integrated to this GitHub repository, distributed and MIT licensed.
  • 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 github-actions bot requested a review from a team as a code owner April 9, 2023 20:59
@github-actions github-actions bot added the ✨ New extension A new extension label Apr 9, 2023
@github-actions github-actions bot added this to Needs review in Extensions review Apr 9, 2023
@github-actions github-actions bot mentioned this pull request Apr 9, 2023
3 tasks
@D8H
Copy link
Contributor

D8H commented Apr 9, 2023

Thank you for submitting an extension.

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

@Kennoir
Copy link

Kennoir commented Apr 9, 2023

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

@D8H
Copy link
Contributor

D8H commented Apr 14, 2023

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

@Kennoir
Copy link

Kennoir commented Apr 14, 2023

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
Copy link

Kennoir commented Apr 14, 2023

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

@D8H
Copy link
Contributor

D8H commented Apr 14, 2023

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?

@Kennoir
Copy link

Kennoir commented Apr 14, 2023

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
Copy link

Kennoir commented Apr 14, 2023

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

@VegeTato VegeTato added the 👨‍👩‍👧‍👦 Community extension An extension submission to be merged ASAP with a lightweight review. label Jun 13, 2023
@Kennoir
Copy link

Kennoir commented Sep 28, 2023

!update
DrawTrails.zip

@github-actions
Copy link
Contributor Author

✅ Successfully updated the extension.

@D8H D8H mentioned this pull request Oct 19, 2023
3 tasks
@Kennoir
Copy link

Kennoir commented Oct 20, 2023

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

@D8H
Copy link
Contributor

D8H commented Oct 20, 2023

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.

@Kennoir
Copy link

Kennoir commented Oct 28, 2023

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.

@github-actions
Copy link
Contributor Author

❗ No updates found. Please check your file.

@D8H
Copy link
Contributor

D8H commented Oct 28, 2023

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

@Kennoir
Copy link

Kennoir commented Oct 29, 2023

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

@D8H
Copy link
Contributor

D8H commented Oct 29, 2023

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

@tristanbob
Copy link
Contributor

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

@tristanbob
Copy link
Contributor

@Kennoir Wow, this extension is really neat! I'm definitely going to be putting this in my game.

GDevelop_DBID0Sycum.mp4

@D8H
Copy link
Contributor

D8H commented Jan 10, 2024

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

@Kennoir
Copy link

Kennoir commented Feb 20, 2024

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.

@D8H D8H moved this from Needs review to Needs changes in Extensions review Mar 19, 2024
@Kennoir
Copy link

Kennoir commented Mar 30, 2024

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

@D8H
Copy link
Contributor

D8H commented Apr 1, 2024

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:

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.

@Kennoir
Copy link

Kennoir commented Apr 5, 2024

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:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👨‍👩‍👧‍👦 Community extension An extension submission to be merged ASAP with a lightweight review. ✨ New extension A new extension
Projects
Extensions review
  
Needs changes
Development

Successfully merging this pull request may close these issues.

None yet

4 participants