![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | umma |
so I am trying to make a simple lod for trees in my scene, there is an area node in front of the player, so whenever a tree enters, the tree becomes visible and when it exits it becomes invisible. However, this is not the case, instead, if trees aren’t always in the area the game drops to 4 FPS and when a tree enters it goes back to the original FPS. any advice?
How are you monitoring the FPS?
have you added something like this
print(Performance.get_monitor(Performance.TIME_FPS))
to a script or did you go into debug in the project settings to set up an FPS monitor?
Gluon | 2022-01-08 21:02
yes i used the “print fps” in project settings, also the scene is relatively big. I used the camera culling, but i would like to get rid of trees behind the player, being that the player wont even see them.
umma | 2022-01-09 00:50
did you solve the problem?
ramazan | 2022-01-09 12:19
nope, I might have to remove the area node, I try adding lod script to the trees but because of the number of trees that was slow too. here is code, i don’t know what wrong
extends Kinematicbody3d
func on area_lod_body_entered(body):
if body.is_in_group("tree"):
body.visible = true
func on area_lod_body_exited(body):
if body.is_in_group("tree"):
body.visible = false
umma | 2022-01-09 12:32
Hiding the object just hides it. That is, it remains available in memory and continues to use memory.
Are trees just for visuals?
i.e. randomize the trees. instance to the stage and queue_free . If you want, there was already similar code. Of course, it would be better for you to write the code yourself.
ramazan | 2022-01-09 13:44
at this point, I don’t think it’s the area node, because here is a scene I just created and it works just fine: test – Google Drive
I will try to look if there is something else causing the problem, btw if I queue_free() something, how would I undo that, is that possible? if it is please tell me how.
umma | 2022-01-09 15:25
use randomized. as the player progresses the trees come then queue_free.
1-2 yıldır bakmıyorum ama burada yolun sağına ve soluna rastgele sahneler yerleştirmiştim. Şayet yanılmıyorsam böyle birşey di.
extends Spatial
Yolbir
func _ready():
randomize()
pass
var rakam = 0
func _process(delta):
rakam += delta
if rakam > 4:
_makineli_poz()
#_makineli_poz()# bas edilmiyor cok fazla
rakam = 0
#set_process(false)
pass
Makineli randomize pozisyon
yolun sagi
var arac_poz = 0.0
var enazr = Vector3(-40, 0, arac_poz)
var enfazlar = Vector3(40, 10, arac_poz)
func _makineli_poz():
arac_poz = $Arac_uc.global_transform.origin.z - 75
var poz_x = rand_range(enazr.x, enfazlar.x) # solda
var poz_y = rand_range(enazr.y, enfazlar.y)
var makine = load(“res://Sahneler/Tuzaklar/Makineli.tscn”)
var m = makine.instance()
add_child(m)
m.transform.origin = Vector3(poz_x, poz_y, arac_poz)
pass
ramazan | 2022-01-09 16:50
anlamadığın yerleri sor
ramazan | 2022-01-09 16:55
Hey, I found the problem, it was the H-terrain addon in the Godot asset library. I wrote a script that deletes the terrain and when it was deleted the fps went back to normal, I will try to use your method in future games, probably a game where land is generated. I really appreciate you helping. btw if I was to use your method, let’s say I have a hilly terrain how would it generate a “z-axis” value that’s accurate with the terrain?
umma | 2022-01-09 18:16
I’m so glad you solved your problem. "I use google translation. I don’t understand the last question
ramazan | 2022-01-10 01:22
soruyordum,
Yönteminizi kullanacak olsaydım, diyelim ki engebeli bir arazim var, araziyle aynı olan bir “z ekseni” değerini nasıl oluşturur?
bu daha mı iyi?
umma | 2022-01-10 13:46
nice question. Is your game for pc or phone?
ramazan | 2022-01-11 07:27
ikisini de yapabilirim. ama şimdilik pc
pc
umma | 2022-01-11 22:45
For pc you can use GridMap or something. So there are too many options. “Search = 3d forest for godot”
ramazan | 2022-01-12 09:17
I had a similar issue where Area 2Ds where lagging my game hard. The reason was because I was adding many Area 2Ds to the scene tree and removing them every physics update.
To solve the issue, I created a buffer of preloaded inactive Area2Ds, and whenever I wanted to add a new area, I would just copy over all the properties of Area 2D I wanted to add to the already-present-in-the-scene Area2D. The lag came from the engine having to look for collisions or something whenever an Area is added to the scene. Removing the area was as simple as just doing monitoring = false and monitorable = false
godot_dev_ | 2022-01-15 16:53