Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Interactive cloth raycast

Discussion in 'Editor & General Support' started by JakobWagner, Mar 1, 2012.

  1. JakobWagner

    JakobWagner

    Joined:
    Aug 2, 2010
    Posts:
    19
    Hi

    I have this:

    var fireRate : float = 0.5;
    private var nextFire : float = 0.0;

    function Start () {

    }

    function Update ()
    {
    if (Input.GetButton ("Fire1") Time.time > nextFire)
    {
    var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
    var hit : RaycastHit;
    if (collider.Raycast (ray, hit, 100.0))
    {
    nextFire = Time.time + fireRate;
    rigidbody.AddForce(Random.Range(30,-30),Random.Range(500,0),Random.Range(30,-30));
    }
    }
    }

    Works great on a ball, it jumps in a random direction when being clicked. Now how can I do something similar to this on a InteractiveCloth? I can't hit it with a raycast because it doesn't have a collider, and I can't addForce because it doesn't have a rigidBody.

    Please help.

    Jakob Wagner
     
  2. Dougieddug

    Dougieddug

    Joined:
    Mar 13, 2013
    Posts:
    1
    Hi, I noticed you hadn't had an answer to this, and thought I'd see if since posting this you had managed to figure it out?

    P.S. Weirdly, you posted this question on my birthday...