Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by jj_antunes · Nov 19, 2013 at 06:35 PM · collisiontrailrenderer

How to make trailrenderer collider?

I´m new at unity and i'm trying to make a game with line collisions. I just found in unity forum a script that makes a trail collider. The question is that only part of that trail makes collision (the part next to the game object attached to it) and i want that the all trail collider. I think there´s something abount linecast but i can not understand what exacly. I realy neeed help. Here´s my script:

 var pencil:GameObject;
 var time : float = 20.0;
 var rate : int = 10;
  var change:String;
 private var arv3 : Vector3[];
 private var head : int;
 private var tail = 0;
 private var sliceTime : float = 1 / rate;
 var hit : RaycastHit; 
  
 function Start () {
     arv3 = new Vector3[(Mathf.RoundToInt(time * rate) + 1)];
  
     for (var i = 0; i < arv3.Length; i++)
        arv3[i] = transform.position;
     head = arv3.Length-1;
     StartCoroutine(CollectData());
 }
  
 function CollectData() : IEnumerator {
     while (true) {
        if (transform.position != arv3[head]) {
          head = (head + 1) % arv3.Length;
          tail = (tail + 1) % arv3.Length;
          arv3[head] = transform.position;
        }
        yield WaitForSeconds(sliceTime);
     }
 }
  
 function Update() {
     if (Hit()){
        Debug.Log("I hit: "+hit.collider.name);
        change=hit.collider.name;
      }
      if(change=="Sphere")
      {
      Debug.Log("hit change");
      Destroy(Sphere);
      }
      
      
 }
  
 function Hit() : boolean {
     var i = head;
     var j = (head  - 1);
     if (j < 0) j = arv3.Length - 1;
  
     while (j != head) {
  
        if (Physics.Linecast(arv3[i], arv3[j], hit))
          return true;
          
        i = i - 1; 
        if (i < 0) i = arv3.Length - 1;
        j = j - 1;
        if (j < 0) j = arv3.Length - 1;
     }
     return false;
     }
 
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image robertbu · Nov 19, 2013 at 06:43 PM 0
Share

There are two separate working examples of this kind of code on UA. One uses Linecast() the other builds a trail of colliders. You can start here:

http://answers.unity3d.com/questions/418759/how-might-i-go-about-making-a-trail-render-that-de.html

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

18 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Assign Edge Collider Points to Trail Renderer Vertices 1 Answer

Physic based golf game - ball bouncing off the connection of colliders on flat surface 2 Answers

Can't seem to get collision to work 1 Answer

Raycast collision detection? 1 Answer

OnTriggerEnter2D not triggering 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges