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 Paul2357 · Jun 23, 2016 at 01:14 AM · c#unity 5line renderergolf

Line Renderer for golf game

So I'm trying to put together a simple golf game and I want to use the line renderer component to show the arc the ball will travel in (or even just a simple point to point showing where it should end up based on the power). The problem is there really aren't any great resources showcasing the use of it in Unity 5, which is what I am using for this game.

I checked out the unity manual for line renderer (located here: http://docs.unity3d.com/Manual/class-LineRenderer.html) and have done a search to find something to show me about how it works.

Does anyone have any suggestions on good tutorials or resources that I can use to learn more about this?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by SarperS · Jun 23, 2016 at 04:46 AM

It is called "trajectory prediction" and there are tons of material regarding this matter. Here is one;

http://answers.unity3d.com/questions/248788/calculating-ball-trajectory-in-full-3d-world.html

Comment
Add comment · 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
0

Answer by MasterLG · Jun 23, 2016 at 04:51 AM

I couldn't think of any resources, and I mostly just screw with things until they work.

Here's a small sample script I whipped up just then called Parabolizer. In a new scene with the default objects, just attach a LineRenderer component to another object and set the material to something you can make sense of, and then attach this script to the same object that has the LineRenderer.

 using UnityEngine;
 using System.Collections.Generic;
 
 public class Parabolizer : MonoBehaviour {
     void Start() {
         // just some set up parameters
         float minY = -5f;
         Vector3 launchVelocity = new Vector3(Random.value * 20f, Random.value * 5f, 0f);
 
         List<Vector3> points = new List<Vector3>();
 
         // gather a list of points along a parabola - not the most elegant way to do things
         Vector3 current = new Vector3(-5f, 0f, 0f);
         while (current.y >= minY) {
             points.Add(current);
             current += launchVelocity * Time.fixedDeltaTime;
             launchVelocity += Physics.gravity * Time.fixedDeltaTime;
         }
 
         // getting the line renderer on this object
         LineRenderer lineRenderer = gameObject.GetComponent<LineRenderer>();
 
         // fiddling with the width
         lineRenderer.SetWidth(0.5f, 0.05f);
 
         // update how many vertices are to be expected
         lineRenderer.SetVertexCount(points.Count);
 
         // setting all positions in one go
         // lineRenderer.SetPositions(points.ToArray());
 
         // setting points individually instead
         for (int p = 0; p < points.Count; p++) {
             lineRenderer.SetPosition(p, points[p]);
         }
     }
 }

I hope this helps as a starting point. Is there anything else you'd like to know?

Comment
Add comment · 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

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

175 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 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

Line Renderer issue 0 Answers

Making a Line Renderer only visible to one Camera 1 Answer

How to use the results of a dice roll? 2 Answers

How do i Instantiate sub-Points with in Multiple Points?? 0 Answers

OnGUI will not show up? 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