0 votes

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?

Godot version godot 3.3
in Engine by (293 points)

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?

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.

did you solve the problem?

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

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.

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: https://drive.google.com/drive/folders/10RxB2OvWI4bWTgQg7fYcS9tSST9i3d23?usp=sharing

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.

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()
#makinelipoz()# bas edilmiyor cok fazla
rakam = 0
#set_process(false)
pass

Makineli randomize pozisyon

yolun sagi

var aracpoz = 0.0
var enazr = Vector3(-40, 0, arac
poz)
var enfazlar = Vector3(40, 10, aracpoz)
func _makineli
poz():
aracpoz = $Aracuc.globaltransform.origin.z - 75
var poz
x = randrange(enazr.x, enfazlar.x) # solda
var poz
y = randrange(enazr.y, enfazlar.y)
var makine = load("res://Sahneler/Tuzaklar/Makineli.tscn")
var m = makine.instance()
add
child(m)
m.transform.origin = Vector3(pozx, pozy, arac_poz)
pass

anlamadığın yerleri sor

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?

I'm so glad you solved your problem. "I use google translation. I don't understand the last question

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?

nice question. Is your game for pc or phone?

ikisini de yapabilirim. ama şimdilik pc

pc

For pc you can use GridMap or something. So there are too many options. "Search = 3d forest for godot"

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

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 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 webmaster@godotengine.org with your username.