create simple 3d objects by code

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

Hello Everyone,

I have discovered Godot for myself a short time ago and have already implemented a few things in 2D, mostly just Youtube tutorials. :wink:

Now I have an idea in 3D and wanted to realise it in a project. I would like to create simple 3D objects dynamically and make them disappear again.Therefore my question can I create in Godot dynamically with GDScript a parallelogram (base with 4 points in 3D coordinates and a depth/volume).
It would be really great if someone can give me a hint or give me some example code lines :wink:

Thanks and see you soon Bobby

Have you looked at the Procedural Geometry page in the docs yet? There are several methods to do what you’re trying to do in Godot, and that page breaks them all down.

Starry | 2021-02-04 05:03

:bust_in_silhouette: Reply From: afk27111

Ye sure thats easy.
You can place a position 3d in your character scene. Then you can create a separate scene for your shape, and it should appear in you resources. So lets just say your parallelogram scene is called, cube.tscn. Then you can do something like:

var 3dshape = preload("res://cube.tscn")

And then using your position 3d you can write

var b = 3dshape.instance()
b.start($position3d.global_transform)
get_parent().add_child(b)

And although this isn’t very clear, it should give you an idea of how to do it.

Thank you afk27111
I will test it right away.

Thx and cya Bobby

PositiverHeld | 2021-02-05 16:22