How to create a spiderweb in Unity?

Hello,

I have a project in which the user controls a spider. I want to enable that the spider can spin a thread by holding down a key. The spider should be able to move on the thread and the web shoudl be affected by prey which will be caught.

However, I don’t know how I should implement the threads. I tried LineRenderer with CharacterJoints and also just adding the Standard GameObjects together.

LineRenderer was a good approach but I don’t know how the spider should be able to walk on those. (see picture)

alt text

If you have a good idea how to implement those spider threads, I would appreciate it.

I would use a procedural mesh to generate the “web thread” that way it will still be an object in which you can attach a collider to and have unity’s physics interact with. Then if you want the spider to “follow” the threads you can write a script that doesn’t allow the spider to move a certain distance away from any of the threads. Something like:

public void FollowThread (){
    if(Input.Getkey(Keycode.W)){
          Vector3 calculatedPosition = this.transform.forward * moveSpeed;
           If(threadmesh.collider.bounds.Contains(calculatedPosition)){
                 //move forward
           }
     }
}

if each web thread is an individual object then you can just add them to a list of gameobjects (or array) and then loop through them to see if their bounds contains the movepoint

alternatively you can check the distance of the movepoint from the threadmeshe’s position with Vector3.distance but this may not work for what you’re trying to do