- Home /
 
 
               Question by 
               rgeade · Jul 04, 2013 at 03:45 AM · 
                physicsclothinteractive clothaddforceatposition  
              
 
              Unable to move InteractiveCloth with AddForceAtPosition
I have a mesh with an InteractiveCloth attached. I am trying to implement a "toss" mechanic that will instantiate the item and apply a force to it, but after several hours of tinkering I still can not get it to work.
  public class Toss : MonoBehaviour {
         
         public GameObject item;
         
         void FixedUpdate () {
             if(Input.GetButtonDown("Fire1")) {
                 Debug.Log("throw it");
 
                 GameObject newItem = (GameObject)Instantiate(item, transform.position, transform.rotation);
 
                         //This works, but is not what I intend
                         //newItem.GetComponent<InteractiveCloth>().externalAcceleration = new Vector3(0,0,-20);
 
                         //This is not working
                         newItem.GetComponent<InteractiveCloth>().AddForceAtPosition(newItem.transform.up * 20f, newItem.transform.position, 5f);
     
             }
         }
         
     }
 
              
               Comment
              
 
               
              Your answer