• 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
1
Question by nioq · Jun 22, 2011 at 06:54 AM · projectiletrail renderer

How to plot projectile path with dotted line

I have a projectile that is similar to a bouncing cannonball. I need to be able to plot a dotted line to predict the path of the projectile.

Since the path needs to take physics into account, I figure it's easier if I actually lob an identical invisible projectile with a Trail Renderer attached. That kinda works well enough for me, except that I can't figure our how to get a material that can get the Trail Renderer to plot the path as a dotted line.

Any ideas? Thanks!

Comment
Add comment · Show 2
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 Eric5h5 · Jun 22, 2011 at 07:36 AM 3
Share

That would be difficult using a trail renderer or line renderer, unless you don't $$anonymous$$d the texture being stretched. But Vectrosity is great for rendering dotted lines: http://www.starscenesoftware.com/vectrosity.html You could get the points for the line by sampling the position of the invisible projectile at rapid intervals.

avatar image nioq · Jun 22, 2011 at 11:16 AM 0
Share

That helped me do exactly what I needed. I see you're the author? Thanks for making my life easier!

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Eric5h5 · Jun 22, 2011 at 06:47 PM

Just to provide an actual answer, here's a script that will make a dotted line path for a rigidbody object using Vectrosity. The lineMaterial should use a texture with a dot in it.

 var lineMaterial : Material;
 var maxPoints = 500;
 var ballPrefab : Rigidbody;
 var force = 16.0;
 
 private var pathLine : VectorLine;
 private var pathIndex = 0;
 private var pathPoints : Vector3[];
 
 function Start () {
     pathPoints = new Vector3[maxPoints];
     pathLine = new VectorLine("Path", pathPoints, lineMaterial, 12.0, LineType.Continuous);
     
     var ball = Instantiate(ballPrefab, Vector3.zero, Quaternion.Euler(300.0, 70.0, 310.0)) as Rigidbody;
     ball.useGravity = true;
     ball.AddForce (ball.transform.forward * force, ForceMode.Impulse);
     
     SamplePoints (ball.transform);
 }
 
 function SamplePoints (thisTransform : Transform) {
     var running = true;
     while (running) {
         pathPoints[pathIndex] = thisTransform.position;
         if (++pathIndex == maxPoints) {
             running = false;
         }
         yield WaitForSeconds(.05);
 
         pathLine.maxDrawIndex = pathIndex-1;
         Vector.DrawLine (pathLine);
         Vector.SetTextureScale (pathLine, 1.0);
     }
 }
Comment
Add comment · Show 2 · Share
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 ahmadshabbir735 · Aug 03, 2018 at 11:42 PM 0
Share

Facing This on Unity 5.3 Please $$anonymous$$ust Help

Assets/Assets/bowandarrow/Scripts/VectorLine.js(13,72): BCE0005: $$anonymous$$ identifier: 'LineType'.

Assets/Assets/bowandarrow/Scripts/VectorLine.js(32,10): BCE0005: $$anonymous$$ identifier: 'Vector'.

Assets/Assets/bowandarrow/Scripts/VectorLine.js(33,10): BCE0005: $$anonymous$$ identifier: 'Vector'.

avatar image Eric5h5 ahmadshabbir735 · Aug 04, 2018 at 01:09 AM 1
Share

Read my answer again, don't just copy the code. (Also it's super-old and wouldn't work with the current version of Vectrosity anyway.)

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Top down shooter trajectory 1 Answer

Projectile in online multiplayer 1 Answer

How do I arc a rigidbody so it lands on a target? 2 Answers

How do I keep track of projectile owners in a networked game? 1 Answer

Projectile not creating particle effects on hit 1 Answer


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