- Home /
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)
If you have a good idea how to implement those spider threads, I would appreciate it.
Answer by Soos621 · Nov 11, 2015 at 07:28 PM
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
Your answer
![](https://koobas.hobune.stream/wayback/20220612044728im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to configure a rope like joint 0 Answers
How would I go about getting the results of a javascript variable to a string inside script? 3 Answers
Web Player Build Templates 2 Answers
Random start on web build 0 Answers
Web radio playing inside unity? 2 Answers