Hi all!
Ok, so my lock-down project is a plant simulator. It grows, all is well except it eventually grows in itself. I was ready to crunch some Quats to avoid this, but the signals I expect from my Areas in case of entering areas are not even fired. I’m obviously doing something wrong but I can’t understand what.
That was confuse. I’m sorry.
I’ll go one step at a time.
Here’s where I connect signals, basically on the plant’s _ready():
$Internode/Area.connect("area_shape_entered", self, "_on_shape_entered")
$Internode/Area.connect("area_shape_exited", self, "_on_shape_exited")
$Leaf/Area.connect("area_shape_entered", self, "_on_shape_entered")
$Leaf/Area.connect("area_shape_exited", self, "_on_shape_exited")
Internode and Leaf meshes are generated, so I get their shape with a:
shape = multimesh.mesh.create_trimesh_shape()
Then I add this shape to the one Area per [Leaf/Internode].
In Leaf.gd:
func add(trans, color, custom):
var owner = $Area.create_shape_owner(self)
$Area.shape_owner_add_shape(owner, shape)
$Area.shape_owner_set_transform(owner, trans)
pinstances.append([trans, color, custom, owner])
pmultimesh.set_instance_transform(count, trans)
…
The reason I’m doing this that way is for performance. Each plant element (node, internode, petiole, blade, etc.) is a Multimeshinstance node ; I tried previously to grow a plant with one mesh node per element and it was so slow (I suppose it was the time for each node to enter the tree). Anyway now each one of them is a single Multimeshinstance where I can change the visible_counter and it runs smoothly.
The downside is that I certainly must use only one Area per collidable element. So I digged into the doc and found you can assign multiple shapes per Area (see supra).
So. I’m not even sure leaves can collide between each other but I try that. And it doesn’t work.
I tried overriding shapes with SphereShapes, no luck.
I tried to add shapes using CollisionShapes, not better.
The only thing that worked was to add basic CollisionShapes to each Area in the editor, then the contact was registered. So I guess I’m mis-adding the shapes to the Areas, but an $Area.getshapeowners() returns filled arrays.
I’m lost.
That was so confuse, here’s my (self-runnable) plant scene for reference: https://files.hanntac.net/s/gkd7Me3f8X3WR3B
Has anybody any idea what’s happening?
Thank you to have read that far!