Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
  • Help Room /
avatar image
0
Question by Crak-n · Sep 30, 2016 at 06:00 PM · linerendererhit.pointlinerender

LineRender weird render points.

Hello, no idea what I doing wrong, i think i check everything and still i don't get it why. Script under post making points from frog to leaf. And everyting going good line going to leaf and making that leaf a Hit. But when line going away from leaf and shoudl find "solid"(water) hit box it make a extra points with no sense for me. And thats is happen only in two reason. If line going back to frog and exit leaf and when going forward and exit leaf. I hope movie should explain what I talking about Here is movie what I talking about: https://sendvid.com/6a39lurt

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine.UI;
 public class liniaskoku : MonoBehaviour
 {
     public float myVelocity = 20.0f;
     public float gravity = 9.81f;  
     public Material[] materials;  
     public int numberOfPoints = 20;
     private Transform cube;
     public Vector3[] points;
     public int shortLenght;
     public float totalDistance = 0.0f;
     public float max_top = 120f;
     public float max_bot = 30f;
     //private GameObject endofgame;
    
     public static float myVelocityPrzelicznik=0.11f;
     private GameObject rodzic;
     private float myVelocityStala = 20.0f;
     private RaycastHit hit;
     private LineRenderer linerender;
     private float width = 0.01f;
     private float myAngle;
     private float sinAngle;
     private int lenght;
     private float actual_angle = 40f;
     public static bool stopscript = false;
     private GameObject hitleaf;
     //private Fading sciemnianie;
     
     
     // public static bool animateTexture = true;
     //  public static float animationspeed = 2;
     //  public static Color textureColor;
     // public static int currentTexture=0;
     //private float currentAnimationOffset;
     // public GameObject render;
     // public Rigidbody projectile;
 
     void Start()
     {
       //  sciemnianie = GetComponent<Fading>();
         cube = GameObject.FindGameObjectWithTag("centrum").transform;
         rodzic= GameObject.FindGameObjectWithTag("centrum");
        // endofgame = GameObject.FindGameObjectWithTag("endgame");
        // endofgame.SetActive(false);
         linerender = GetComponent<LineRenderer>();
         linerender.SetWidth(width, width);
         stopscript = false;
     }
     void Update()
     {
         if (stopscript == false)
         {
 
 
           //  Debug.Log(myVelocityPrzelicznik);
            // Debug.Log(myVelocity);
             if (myVelocityPrzelicznik < 0.2f)
             {
                 myVelocityPrzelicznik = 0.2f;
             }
             myVelocity = myVelocityPrzelicznik * myVelocityStala / 2;
             //Debug.Log("po prze" + myVelocityPrzelicznik);
            // Debug.Log("po v" + myVelocity);
             if (Input.GetKey(KeyCode.DownArrow) && actual_angle > max_bot)
             {
                 transform.Rotate(Vector3.left);
                 actual_angle -= 1;
                 
             }
             if (Input.GetKey(KeyCode.UpArrow) && actual_angle < max_top)
             {
                 transform.Rotate(Vector3.right);
                 actual_angle += 1;
             }
             if (Input.GetKey(KeyCode.RightArrow))
             { cube.Rotate(Vector3.up);
               //  Debug.Log(cube.rotation);
             }
             if (Input.GetKey(KeyCode.LeftArrow))
             { cube.Rotate(-Vector3.up);
                // Debug.Log(cube.rotation);
             }
 
             myAngle = Mathf.Cos(((Vector3.Angle(transform.forward, cube.forward)+0.1f) / 100));
             sinAngle = Mathf.Sin(((Vector3.Angle(transform.forward, cube.forward) + 0.1f) / 100));
             points = new Vector3[numberOfPoints + 1];
             linerender.SetVertexCount(points.Length + 1);
             linerender.SetPosition(0, transform.position);
             lenght= numberOfPoints;
 
             if (shortLenght > 0)
             {
                 lenght = shortLenght;
             }
 
             totalDistance = Vector3.Distance(transform.position, points[0]);
 
             for (int t = 0; t < lenght; t++)
             {
 
                 points[t] = transform.position;
                 var tempX = myVelocity * t * 0.2f * myAngle;
                 points[t] = points[t] + cube.forward * tempX;
                 var tempY = myVelocity * t * 0.2f * sinAngle - 0.2f * gravity * (Mathf.Pow(t * 0.2f + 0.01f, 2));
                 points[t] = points[t] + cube.up * tempY;
                 linerender.SetPosition(t + 1, points[t]);
 
                 if (t > 0)
                 {
                     if (Physics.Linecast(points[t], points[t - 1], out hit))
                     {
                         if (hit.transform.tag == "leaf")
                         {
                             
                             linerender.SetVertexCount(t + 2);
                             shortLenght = t + 2;
                             linerender.SetPosition(t + 1, hit.point);
                             points[t] = hit.point;
                             break;
                         }
                         if (hit.transform.tag == "solid")
                         {
 
                             linerender.SetVertexCount(t + 2);
                             shortLenght = t + 2;
                             linerender.SetPosition(t + 1, hit.point);
                             points[t] = hit.point;
                             break;
                         }
 
                     }
 
                     else
                     {
                         linerender.SetVertexCount(numberOfPoints + 1);
                         shortLenght = 0;
                     }
                    // if (t != (lenght - 1))
                     //{
                      //   totalDistance += Vector3.Distance(points[t], points[t - 1]); //Dodawanie odległości od kolejnych punktów linii
                     //}
                 }
             }
 
             linerender.material.HasProperty("_Color");
             
 
             
             // linerender.SetWidth(width, width);
         }
 
         if (Input.GetKeyDown(KeyCode.Space))
         {
 
             if (hit.transform.tag=="leaf")
             {
                 hitleaf = hit.transform.gameObject;
                 count_points.dodaj = true;
                 rodzic.GetComponent<projectileArc>().FollowPoints(points,lenght,hitleaf);
             }
             else
             {
                 hitleaf = hit.transform.gameObject;
                 if (hitleaf.CompareTag("solid"))
                 {
                     CAMERA_FOLLOW_FROG.sledzenie_zabki = false;
                     Debug.Log("END OF GAME GOING SLEEP");
                     //endofgame.GetComponent<koniecgry>();
                     //endofgame.SetActive(true);                    
                 }
                 rodzic.GetComponent<projectileArc>().FollowPoints(points, lenght, hitleaf);
             }
                 
         }
     }
 }

alt text

errrr.jpg (206.0 kB)
Comment
Add comment
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

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

73 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 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 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 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 avatar image

Related Questions

Inverted numCapVertices when baking linerenderer 0 Answers

Using LineRenderer, how can I draw a single path passing through more than two points? 1 Answer

Alternative to linerenderer for Tower Defence path display 2 Answers

Drawn line twists and becomes invisible 0 Answers

Line Renderer 2d Follow the edge 0 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