The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

I'm making a Tron clone, the trail of the cycles generates a lot of vertexes every second and they never disappear.
The render is a Mesh.Primitive_triangles type, I thought it would have been easy to render but after a while the game starts to go very slow.
What are the settings of the material (spatial) that I should use? Are there other ways to improve performance?

Idk if the image is visible

Godot version 3.2.3
in Engine by (18 points)
edited by

Actually I'm using a SurfaceTool inside a MeshInstance Node.
Immediate Geometry doesn't let you create collisions from meshes, that said I' going to try reducing the amount of vertexes as you said

Ok I'm noob and I can't fix the code myself. I created a timer for the generation of the vertexes, it has to be 0.017 seconds or less, or the trail is not rendered precisely.
A second timer creates the collision box every 0.07 seconds, it does improve performance if i increase the time, but i need the collisions to exist as soon as possible.
This is the code:

func _on_Timer_timeout():
if is_target and wr.get_ref():
    surfTool.begin(Mesh.PRIMITIVE_TRIANGLES)
    surfTool.add_vertex(prev_point1)
    surfTool.add_vertex(prev_point2)

    surfTool.add_vertex(Vector3(p.x,p.y+l,p.z))
    prev_point1 = Vector3(p.x,p.y+l,p.z)

    surfTool.add_vertex(Vector3(p.x,p.y-l,p.z))
    prev_point2 = Vector3(p.x,p.y-l,p.z)

    surfTool.add_index(0)
    surfTool.add_index(1)
    surfTool.add_index(2)

    surfTool.add_index(1)
    surfTool.add_index(2)
    surfTool.add_index(3)

    surfTool.index()

    surfTool.commit(m)
    set_mesh(m)
else:
    get_parent().queue_free()

func _on_Refresh_timeout():
get_parent().get_child(1).shape = mesh.create_trimesh_shape()

it's not clear what you have done since we are missing what prev_point and p are, but does this work or not?
if it works, do you notice any stuttering?

ps: i dont know if that's faster, and sometimes it brokes the collision shape, but have you thought about using scale?

pps: for the timer, i would have used a simple counter, like (but i dont know which method is the most efficient tbh)

var t=0
func _process(_delta):
  t+=1
  if t>refresh_time:
     t=0
     do_stuff()

It works, but after a while the game gets slower. I thought about resizing the mesh, but it would scale it on both directions
prev points are the previous point that I used a vertexes, and p is the position of the player

yeah you have to scale it and move it at the same time.
strange though, if vertex count stays the same it shouldnt get worst over time

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.