0 votes

Hi,

I am currently trying to build a robocraft-like game (is about building a vehicle using cubes, weapons, wheels, thrusters... ) and I got incredibly stuck.

Let me explain:

I have a scene "cube", with a script attached that controls health and other events.
The cube root node is a rigid body with a box collision shape and a meshinstance loaded from a .obj

Now I define a main scene with a spatial node called "Vehicle", which has two childs:
- a spatial "orbital_camera" node for a camera that orbits the vehicle (works ok)
- a spatial node called "VehicleBody" which holds all the vehicle geometry.

The scene also has a static body called "Map", that consists in a flattened box acting as ground.

Question A:
If I instance some "cube" scenes as child of VehicleBody, they physically behave like completely separated objects, despite being on the same node. What am I missing here?

Question B:
If I change the node type of "VehicleBody" to rigid body, cubes seem to be locked in place between each other (good thing), but they will not collide with anything (bad thing) or interact physically. I understand that this is due to their global position being attached to a rigid body without collision shape?

Question C:
If I change de node type of "VehicleBody" to rigid body, and by gdscript I attach the collision mesh and visual mesh, it collides and cubes stay together. But then I lose the capability for each cube tracking their own things without any other external control. Also, they have no weight and the vehicle moves weird. This implementation could work by applying a gravity force on each cube at every physics step, checking the state of every cube in a global list, handling block removal by the parent node... I find this way of proceeding nonsensical and perfomance killing in comparison with the idea of scene instancing and keeping everything as loosely tied as possible. Is this the only way possible?

After reading all the painfully sparse documentation, examples, qa and everything, I think I am missing something big here, but I just can't figure out.

Thank you.
Javier.

in Engine by (16 points)

1 Answer

0 votes

Some news:

Partially solved this, seems working so far. I can define a set of blocks with some functionality and spawn them with their individual collision meshes. The downside is that I have to manually recreate gravity and inertia tensors (g was easy, inertial left for later). Now I am crawling to get steering wheels to work properly.

This video shows my first constraint-based approach (not the current implementation, will post in the future if it works):

https://www.youtube.com/watch?v=ODv99SvjWQw

Also, this is a similar unanswered question:
https://godotengine.org/qa/28594/rigid-compound-body-consisting-multiple-physical-properties?show=28594#q28594

by (16 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 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.

Categories