1
\$\begingroup\$

I need some help with a softbody mechanic on a player in unity and I don't know how to approach it yet. I want to try rigidbody collision on individual sections of the mesh, or mess with the cloth component. So far with the cloth component, my player's rigidbody and collider move outside the actual mesh. Idk how to get my movement script to actually move the cloth.

Incase you want the movement script:

using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
public Rigidbody rb;

public float fowardForce = 60f;
public float sidewaysForce = 50f;

void FixedUpdate()
{


if (Input.GetKey("w") )
    {
    rb.AddForce(0, 0, fowardForce * Time.deltaTime);
}

if (Input.GetKey("s") )
    {
    rb.AddForce(0, 0, -fowardForce * Time.deltaTime);
}

    if (Input.GetKey("d") )
    {
    rb.AddForce(sidewaysForce * Time.deltaTime, 0, 0);
}

if (Input.GetKey("a") )
    {
    rb.AddForce(-sidewaysForce * Time.deltaTime, 0, 0);
}

    if (Input.GetKey("i") )
    {
    rb.AddForce(0, fowardForce * Time.deltaTime, 0);
}

    if (Input.GetKey("o") )
    {
    rb.AddForce(0, -fowardForce * Time.deltaTime, 0);
}

I don't really care if the softbody uses the cloth component, I mainly care that whatever method I use, it is easy for me to get and understand. If anyone can show me code to achieve this, it would be very appreciated.

\$\endgroup\$
4
  • \$\begingroup\$ Can you show us how you want your soft body to behave? There are a whole lot of different shapes and behaviours soft bodies can exhibit, so the better we understand your game's specific needs, the better we can help you achieve them efficiently. \$\endgroup\$ – DMGregory Oct 14 '20 at 20:01
  • \$\begingroup\$ for instance are your trying to achieve movement like human: fall flat? or maybe gang beasts? \$\endgroup\$ – Millard Oct 15 '20 at 0:37
  • \$\begingroup\$ This is basically a simulator for cells. I want to add organelles in a membrane that flow within the membrane as it crashes around and crap. I would like different settings for different cellular membranes such as soft for looser membranes that instantly bounce back for looser membranes, and something more like a metal can setting that deforms almost permanently and is a bit more tough. \$\endgroup\$ – Animation Space Oct 23 '20 at 4:10
  • \$\begingroup\$ You know, maybe I made the scope a little too ambitious. I mainly just want a method of deforming a mesh's vertices and having a reform variable where it pops back into shape. Any ideas? \$\endgroup\$ – Animation Space Oct 27 '20 at 2:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.