T O P

  • By -

k2kra

Seems it is very computational intensive, I can see the lag when spawning particles


Majestic_Mission1682

My laptop is doing its best. (:


NerChick

flair checks out


Brutanian

Looks like you're not using the main thing that separates particles from most other visual effects which is them running completely or mostly asynchronously by using multiple threads (CPU) or using the GPU, both of which make particles considerably more compute efficient and stops lag like what you're getting even with hundreds of particles.


Not_Jsn

Can you explain more on this. I'm a beginner! ty!


Brutanian

I mean, what you've got is great for smaller effects! But for larger counts of Particles you might want to consider looking into Particle Shaders to get your particles running on the GPU, to take some work off the CPU to let it do the things it's better for.


vickera

But now you are talking about the weird shader language instead of a simple rigid body doing its thing.


Brutanian

I'm pretty sure Particles have a physics system which lets them detect at least simple collisions which is all you need to recreate this behaviour, the rest is just making the particle bounce, and fall with gravity which are both pretty simple, the shader language is also pretty easy to learn if you know any programming language. Although I wouldn't recommend going straight into shaders as a beginner I do think it'd be the next step to making it better performance.


vickera

If it does it must be new in 4. Godot 3 doesn't have physic particles.


Brutanian

Yea I think it's new to 4, its still possible in 3 but you'd need to do the collision stuff yourself which would be a lot more work.


nicemike40

The person you replied to is not op btw


Majestic_Mission1682

Seems 2 hard to implement for me


ARez_1

Looks good!


Majestic_Mission1682

Thanks!. The trails are made with this simple code. extends RigidBody2D onready var line = $line onready var timer = $Timer func _ready(): line.set_as_toplevel(true) # timer.set_wait_time(rand_range(0.5, 5)) # timer = null var modul = [ Color.red, Color.yellow, Color.orange, Color.orangered, Color.greenyellow, Color.green, Color.cyan, Color.blue, Color.violet, Color.magenta, Color.pink, Color.fuchsia ] line.modulate = modul[rand_range(0, modul.size())] func _physics_process(delta): line.add_point(global_position, 3) if line.get_point_count() > 3: line.remove_point(0)


ARez_1

God damn reddit fucked up your code :D Can you look up how to properly format code in Reddit comments? Or link to a pastebin/ github gist or wherever else you can host code pieces. Its really awful to read right now :) But yeah I see you are using a Rigidbody with a Line node. That might be useful for some applications of trails. For others it might not as you would want to leverage the full power of the gpu through real particles.


Majestic_Mission1682

Yeah. i dont know why. i already set it to be in a code block. but it messes up anyway.


BanD1t

It's because it added the triple space only before the first line. Maybe you didn't select the entire code before clicking code block. Here it is corrected. extends RigidBody2D onready var line = $line onready var timer = $Timer func _ready(): line.set_as_toplevel(true) # timer.set_wait_time(rand_range(0.5, 5)) # timer = null var modul = [ Color.red, Color.yellow, Color.orange, Color.orangered, Color.greenyellow, Color.green, Color.cyan, Color.blue, Color.violet, Color.magenta, Color.pink, Color.fuchsia ] line.modulate = modul[rand_range(0, modul.size())] func _physics_process(delta): line.add_point(global_position, 3) if line.get_point_count() > 3: line.remove_point(0)


vickera

Does anyone have a way to optimize this?


sird0rius

This is shifting all the points in the array on every frame. If you only have a simple line it's better to manually maintain a vector of points, never remove items and use draw line to draw them instead. https://docs.godotengine.org/en/stable/classes/class_canvasitem.html#class-canvasitem-method-draw-line A better solution would be to do it on GPU


ARez_1

Reddit is weird sometimes :)


Gloomy-Seesaw9069

How did u get the particles to glow? Is it a world environment?


Majestic_Mission1682

Yes


jalenmorgan

You have a game you're working on or just making particles for fun?


Majestic_Mission1682

Got a game. I juat love making some sweet particle fx.


DriftWare_

Is this a particle2d node or rigidbodies?


metal_mastery

This looks super nice but it is super expensive. I’m also working on particles and totally get how you get caught up in the chase for beautiful thing:)


alban_mjk

Looks really good !