Should I be instantiating a new GameObject or replacing the mesh and materials?
Hello, I know something like this has been asked before, however that post is a few years old and I'd rather avoid posting there, and my case is a little different.
I'm creating an RTS and I have a question regarding my road creation script. Essentially I'm instantiating a series of gameobjects in a straight line based on the distance the player has drawn, and adding them to a list. All instantiations happen in one call of the update function since the player draws the distance in real-time and when a click is detected, the objects are instantiated in a for loop. I'm only allowing the player to create roads aligned with the x or z-Axis. In the case that there is an intersection or turn, I instantiate the appropriate new gameobject and then destroy the straight road segment in that position.
Should I be "replacing" the gameobject like that or is it better simply changing the mesh and materials for the gameobject that I would otherwise destroy? Do keep in mind that this "replacement" wouldn't happen very frequently, a maximum of two times per the road placement script's update function in the "extreme" case the player wants to connect two parallel roads, and one or two extra instantiations at most don't seem much, but I may very well be mistaken.
Thank you.
Your answer
Follow this Question
Related Questions
Removing Tris/Verts/Polygons from an merged mesh? (C#) 0 Answers
Raycast doesn't find mesh 0 Answers
How to merge meshes in script for 65536 instances of the same primitive 0 Answers
One object with bones vs several objects without bones(animation) 1 Answer
Rendering performance of single large mesh vs multiple smaller meshes 0 Answers