Unity NVIDIA Flex, add force

598 views Asked by At

This might be a rather niche question, but maybe someone can help me out. I used the NVIDIA Flex plugin for unity to create a soft body object in a sphere shape and I would like to move it around by applying an impulse to it. Without Flex, I would just use a rigidbody and the addforce function. But because Flex uses it's own Physic calculation and sets the position of the object accordingly, at least that's what it looks like to me, the addForce is just completely ignored...

So how would I add the force to the Flex-Object?

1

There are 1 answers

0
Kristijonas Grigorovičius On BEST ANSWER

you need to get reference to FlexActor component, and then add impulse

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using NVIDIA;
void Start()
{
 FlexComponet = GetComponent<NVIDIA.Flex.FlexSolidActor>();
}
public float mul = 100f;
 void Update()
    {  
        input = new Vector3(Input.GetAxis("Horizontal"),0,Input.GetAxis("Vertical"));
        FlexComponet.ApplyImpulse(input*mul);

    }