This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes
in Engine by (83 points)

Is it possible?!
I found hterrain_brush.gd file for painting functions, I instanciate that and call paint method, but I get Assertion Failed error.

It is possible (even without brush), but I never tested using the brush in game and maybe it's not exactly fit to your needs. Which error are you getting?

I use these two line for painting a color on terrain, but I get "Assertion Failed" on hterrainbrush.gd Line 536. It seems CHANNELCOLOR is not loaded or accessible that momemt.

var brush = preload("res://addons/zylann.hterrain/hterrain_brush.gd").new()
brush.paint($HTerrain, collsioin_info.position.x, collsioin_info.position.z, brush.MODE_COLOR)

Looks like only the heights can be accessed at runtime, actually. Colors are not because most of the time it is not really needed so no point wasting a large amount of memory.

I need to add an option somewhere to make it so channels stay in memory at runtime.
At the moment, if want to access it, I think you should comment out the if located in hterrain_data.gd line 1077: https://github.com/Zylann/godot_heightmap_plugin/blob/30f0e6022903825aef2b006e5abb97065668ec49/addons/zylann.hterrain/hterrain_data.gd#L1077

Another error on hterrain_brush.gd Line 283 occured.
Invalid call. Nonexistent function 'get_width' in base 'Nil'.

The brush doesn't initialize its shape by default. You need to specify it by calling set_radius(radius in pixels).

Thanks Zylann! Finally It works!
For someone who read later, after commenting if located in line 1077 of hterrain_data.gd with following lines we could paint terrain at runtime.

var brush = preload("res://addons/zylann.hterrain/hterrain_brush.gd").new()
brush.set_color(Color.red)
brush.set_radius(10)
brush.paint($HTerrain, collsioin_info.position.x, collsioin_info.position.z, brush.MODE_COLOR)

I think if you add an option somewhere for loading channels to memory at runtime (so does not need to change addon source files), It could be a good temporal solution for https://godotengine.org/qa/49476/apply-objects-movement-effect-on-terrain (more specific on texture painting)

Good to hear it works fine :)
However careful with the other question you linked, modifying the terrain to leave skidmarks is extremely expensive. Decals or simple mesh strips are often preferred to do this.

Would you please give me some link or resources about them?
I found this https://github.com/Mr-Slurpy/Screen-Space-Decals, but I don't know how actually its works., and are its known limitations serious or not?

I never used this in Godot yet, so I don't know more than you do.

Anyway very thanks Zylann!

hi Zylann, ive got a similar problem:
How can i modify the terrain while runtime?

1 Answer

0 votes

Comment the if which is located in line 1077 of hterrain_data.gd and then use following lines:

var brush = preload("res://addons/zylann.hterrain/hterrain_brush.gd").new()
brush.set_color(Color.red)
brush.set_radius(10)
brush.paint($HTerrain, collsioin_info.position.x, collsioin_info.position.z, brush.MODE_COLOR)

For more info read above comments.

by (83 points)
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 Frequently asked questions and 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 [email protected] with your username.