Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 lloydmarquart · Jul 31, 2018 at 05:52 PM · trailrenderertrail renderer

Trail Renderer tracking problem

Hey everyone!
I'm pretty new to Unity, and I followed a tutorial to create a replica of the Fruit Ninja game, and it included a Trail Renderer for registering the blade cuts.
An empty GameObject instantiates BladeTrail objects, which have a trail renderer on them, and then destroys them. It's difficult to describe, but my problem is that, even though these instances are supposed to be separate objects, they constantly start at the ending point of their predecessor rather than immediately from mouse position (this video shows it pretty clearly).
Even with the exact code the YouTuber used, I get this problem. Does anyone have a solution to this? Here's the code on the Empty Object that instantiates the cuts(which have a trail renderer on them):

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class Blade : MonoBehaviour {
 
     bool isCutting = false;
     public GameObject bladeTrailPrefab;
 
     GameObject currentBladeTrail;
 
     Rigidbody2D rb;
     Camera cam;
 
     void Start()
     {
         cam = Camera.main;
         rb = GetComponent<Rigidbody2D>();
     }
 
     void Update () {
         if (Input.GetMouseButtonDown(0)) 
         {
             StartCutting();
         } else if (Input.GetMouseButtonUp(0)) {
             StopCutting();
         }
 
         if (isCutting) {
             UpdateCut();
         }
     }
 
     void UpdateCut () {
         rb.position = cam.ScreenToWorldPoint(Input.mousePosition);
     }
 
     void StartCutting () {
         isCutting = true;
         currentBladeTrail = Instantiate(bladeTrailPrefab, transform);
     }
 
     void StopCutting () {
         isCutting = false;
         currentBladeTrail.transform.SetParent(null);
         Destroy(currentBladeTrail, 2f);
     }
 }


Thanks for anyone taking the time!

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

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

Related Questions

Unity Trail Renderer acts ... differently on MAC 0 Answers

Trail renderer overlapping 0 Answers

Unity3d 2017 trail renderer behaving weird 0 Answers

How to make bezier curve and trail effect for 2D puzzle game? 0 Answers

My trail renderer is on the wrong layer when export on Xcode on a iPad or a iPhone 4S . What am I gonna do ?! 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