Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I use the Procedural Generation example Script? #195

Closed
elliotrpage opened this issue Aug 29, 2020 · 5 comments
Closed

How can I use the Procedural Generation example Script? #195

elliotrpage opened this issue Aug 29, 2020 · 5 comments
Labels
question Further information is requested

Comments

@elliotrpage
Copy link

Hello,

Thank you for writing this helpful tool. Apologies for what is likely a basic question, but how do I use the Procedural Generation Script?

I have created a Spatial Node Scene and copied the example script into the GDScript attached to the Node. My assumption was that I would run the Scene (using F6) and a terrain node would be created and attached in the tree (due to the add_child call) however this assumption appears to be entirely wrong as nothing happens.
No errors appear in the debugger when I run the Scene and I added some basic print commands to the script to see if it was getting caught anywhere but it runs through the whole function when run.

Again, apologies if I am missing something basic!

Yours,
Elliot

@Zylann
Copy link
Owner

Zylann commented Aug 30, 2020

Did you place a camera in the scene to actually see that terrain? If all you have is the spatial node, then by default Godot will look straight from the origin, and the terrain might have generated above, out of sight.

Try adding a camera (which you make current in the inspector), place it about 100 units above 0, increase its far clip to 1000 and make it look down, you should see something appear.

@Zylann Zylann added the question Further information is requested label Aug 30, 2020
@elliotrpage
Copy link
Author

Thank you very much! This has done the trick and I can see the terrain when I run the Scene.

The one step I was hoping for (but may be incorrect in assuming this would work) is that the generated terrain would appear in the Editor itself as a Node so I could save it and edit/ use elsewhere.
Would I need to turn the procgen script into a "tool" instead and run it within the editor?

Many Thanks,
Elliot

@Zylann
Copy link
Owner

Zylann commented Aug 30, 2020

You could make it tool, but you could also use ResourceSaver.save() on the data resource.
Note that for generating a terrain in editor, there is a tool in the plugin https://github.com/Zylann/godot_heightmap_plugin/blob/master/addons/zylann.hterrain/doc/main.md#terrain-generator

@elliotrpage
Copy link
Author

Thanks, I'll give that a go.
I've been using the Terrain Generator in-editor but (unless I am missing something) this does not provide the programmatic texture application that is present within the ProcGen script - I'm trying to spit out lots of individual terrain nodes so I can pick the ones I like and use these for individual levels.

Apologies, I should have provided more detail at the start!

@elliotrpage
Copy link
Author

I think I got it! I needed to terrain.set_owner() in the script, like described in your answer to this other question!
https://godotengine.org/qa/15486/create-nodes-in-the-editor-from-script

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants