Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Move Softbody to position
#5
(21-04-2022, 10:40 AM)josemendez Wrote: There's several ways you could go about this. One is to specify particle positions, but that would overwrite simulation results. Assuming you want the softbody to still react to collisions and accelerations while following the red ball, the simplest approach is to use the softbody.AddForce() function. This works just like Unity's rigidbody.AddForce().

Calculate a vector from the softbody to the red sphere, scale it by the intensity of the force you want to apply, and then call AddForce(yourScaledForceVector). That will make the softbody follow the sphere.

Let me know if I can be of further help,
The softbody is swinging faster and faster, is there an calculation to not swing around the red ball?

This is my current script:

Transform tr;
    public Transform trTarget;
    public ObiActor actor;

    void Start()
    {
        tr = transform;
    }

    public float speed = 6;
    void Update()
    {
        actor.AddForce((trTarget.position - tr.position) * speed, ForceMode.Acceleration);
    }



Result:

[Image: ea3f53643998097032ec8924373ddb36.gif]
Reply


Messages In This Thread
Move Softbody to position - by Cysar - 20-04-2022, 06:28 PM
RE: Move Softbody to position - by josemendez - 20-04-2022, 06:37 PM
RE: Move Softbody to position - by Cysar - 20-04-2022, 07:10 PM
RE: Move Softbody to position - by josemendez - 21-04-2022, 10:40 AM
RE: Move Softbody to position - by Cysar - 21-04-2022, 11:36 AM
RE: Move Softbody to position - by josemendez - 21-04-2022, 12:09 PM
RE: Move Softbody to position - by Cysar - 21-04-2022, 02:21 PM
RE: Move Softbody to position - by josemendez - 21-04-2022, 02:41 PM
RE: Move Softbody to position - by Cysar - 21-04-2022, 02:51 PM