0 votes

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);


            GetParent().GetNode<Spatial>("bullets").AddChild(bullet_scene);

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

enter image description here

in Engine by (74 points)

1 Answer

0 votes
Best answer

Hi.
the error most likely occure because you call lookat before addchild. 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 "treeentered" 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:
https://docs.godotengine.org/en/stable/tutorials/optimization/using_multimesh.html

by (3,932 points)
selected by
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.