how do u apply a force from a given point to all directions to rigiddynamicbodies3D without using raycasts?
apply force in all directions from given point to rigidbodies
There are two function you can use, apply_force() or apply_impulse() (depending on what you are doing). You pass in a Vector3 of the point you want to hit, so you can generate this through any means, a ray cast is not needed.
https://docs.godotengine.org/en/latest/classes/class_rigiddynamicbody3d.html
Yeah, you have to find out which rigidbodies are close enough to be affected. Maybe a circular area and find overlapping bodies. Then apply an impulse in the direction from the point to the body. I haven't tried it or anything. That's what I think I would try.
I think you would use an Area3D for this.
You can create an Area3D with a sphere collision mesh. Leave it on the tree somewhere and just hide/disable it. Then when you need it (for example, if a grenade goes off), move it to the grenade position then have it check for overlapping bodies. The function is called get_overlapping_bodies().
https://docs.godotengine.org/en/latest/classes/class_area3d.html
Then, with the list that it returns, you can call the apply_impulse() function and pass in the center of the sphere.
cybereality that sounds like what i need, ill look into it, tnx
- Best Answerset by DJM
Yeah, using an Area3D is what I did for the grenades in my Godot VR starter tutorial. It looks like it was removed in the latest documentation, but the Godot 3.3 docs still link to it: https://docs.godotengine.org/en/3.3/tutorials/vr/vr_starter_tutorial/vr_starter_tutorial_part_two.html#adding-a-bomb
- Edited
TwistedTwigleg tnx for the example, exactly what i needed
only these lines give error, the rest i could convert to godot4 api
collision_layer = 0
collision_mask = 0
mode = RigidBody.MODE_STATIC
DJM hmm, I’m not sure. It looks like the collision layer and mask are still properties: https://docs.godotengine.org/en/latest/classes/class_collisionobject3d.html#class-collisionobject3d
For the physics mode, I think you need to use the freeze mode property: https://docs.godotengine.org/en/latest/classes/class_rigiddynamicbody3d.html#class-rigiddynamicbody3d-property-freeze-mode
I am not totally sure though, I have not used Godot 4.0 in roughly a year so I’m not 100% sure it is the equivalent.
TwistedTwigleg
im probably getting the error cause in your tutorial u ve set up your custom vr rigidbody.
wich is what ive removed. i need to pass something before '.collision_layer' etc
Wasn't there a change to PhysicsBody
in godot 4? Again, I haven't yet invested much time in the development version.