Closed MrJox closed 9 months ago
Hi. The softbody itself contains a lot of rigidbodies. I could provide a function that applies impulse on all of them, but I'm not sure thats whats expected. You van try getting all rigidbodies children and try some logic. You can also get the center rigidbody and move that.
As I'm a little newbie in this I would love to see an example or two
Ill try to add one when i have some time. What is ur use case though? What are you expecting to happen in your game? How do you want to move the softbody?
I want to shoot at the softbody blob, make it have a visual impact in place of collision, as well as change the blob's position in the direction of the shooting
Can you provide also an image or something of what you want? Or if you find in an example somewhere or if you can replicate with a rigidbody.
So roughly, here's the idea:
Interesting. And is this not what happens when you hit the softbody right now? That would be what I would expect to happen without needing to apply any force to it.
I fire bullets at it and push myself against the softbody, however it has no effect. The physics work only with gravity. Maybe I'm missing something in my setup though.
The softbody is setup this way: Node2D (root node) -- SoftBody2D (texture is provided, bones are present)
If I simply drop the body from air against a surface, it works exactly as it should. But the problem is I don't understand how to apply external forces to it, like an impulse to the side
Can you provide an example project or a video?
What exactly would you like to see? I cant share the project as its NDA
A test project where you hit a softbody and it doesnt move. In my tests the softbody moves if it gets hit by another body, even if gravity is 0.
Where can I see you project? It may help me understand what I'm missing
Hi, I was able to apply external force by calling apply_central_force()
on a specific bone RigidBody2D.
Is there a way to figure out which bone was closest, when external object collided with the soft body?
Not unless you get all rigidbodies and check which one is closest.
I'm adding now some new samples for your use case though.
Thank you very much!
Meanwhile I did a few more tests myself - I created a softbody (its just a solid circle texture) with the following parameters: Vertex interval - 173 Radius - 10 Total Mass - 10 Shape Type - CIrcle Joint type - pin No physics material override Texture size is 512x512
Scene hierarchy is the following: CharacterBody2D (Root) -- SoftBody2D -- RigidBody2D (for bullet collision test) ---- CollisionShape2D -- StaticBody2D (for ground collision test) ---- CollisionShape2D
CharacterBody2D node transform is scaled down to 0.1 on both axes.
The idea was to test how the softbody reacts to collision against an external force - a bullet that hits the softbody from horizontal direction. I set bullet mass to a ridiculous number (1000000 kg). The softbody mass is 10 kg. The bullet speed is 2000 * delta in X direction.
Test result: Bullet reaches the softbody, bullet gets stuck against the softbody and doesn't affect it
Can you as well send a video of this? From screenshot seems like the softbody isnt constructed but its a voronoi diagram instead.
Also just to reduce of what could go wrong, try for now to not scale softbody.
Also if u can get on project discord, itll be easier to check whats wrong there.
Scale indeed was one of the reasons it didnt work very well. I think node scale forfeits bone radius, which results in wrong behaviour when external rigid body collides into bones
Added an example with apply_force in tutorial.gd file.
Hi, I cannot apply an external force to the softbody. The softbody itself behaves exactly how I want it - it's a soft circular blob.
Now I want to fire at that blob and make it react. How can I achieve it? Functions such as apply_impulse() don't work