LookAt error at 3D

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By daniel500013

Hi i have some question because while instance bullet hole i tried rotation this to player so i made this script (i made scripts in c#)

            PackedScene bullet = (PackedScene)ResourceLoader.Load("res://weapon/scene/BulletHole.tscn");

			Spatial bullet_scene = (Spatial)bullet.Instance();
			bullet_scene.Translation = (Vector3)collision.GetCollisionPoint();
			bullet_scene.LookAt((collision.GetCollisionPoint() + collision.GetCollisionNormal()), Vector3.Up);


but when i start game and tried shoot some objects to test my bullet hole rotation works i got this error and i don’t know why i got this

:bust_in_silhouette: Reply From: klaas

the error most likely occure because you call look_at before add_child. But even when you change the order of the calls it may result in this error because you have to wait until the node signals “tree_entered” or better “_ready”.

My advice would be to use multimesh when spaning bullet holes. They only need one draw call for all of your bullet holes. This is can be a hugh performace increase. Also you can easily spawn new instances without creating new objects.
Read more about it here: