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 Joseph Lerner · May 09, 2015 at 01:43 AM · c#physics3dfps

Trace 3D Basketball Shot

I'm making a game in which you shoot basketballs at a hoop in a first-person 3D world. Your player is the standard Unity 1st person player controller. When you shoot, a basketball prefab is instantiated on your player and is pushed up by a force and falls down due to gravity. This means your shots arc.

I want to create a tracer of your potential shot so you can aim better.

I have been working on this for hours by fiddling around and searching the internet, but the tracer I made isn't accurate. I'm guessing the solution is buried in some math I haven't learned yet. I really would appreciate some guidance.

I only know C#

Thanks

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by smallbit · May 09, 2015 at 05:37 AM

I had similar problem with my plane game in which i needed to display the aim for bomb drop, bomb was being given the initial velocity with the plane speed. Anyway I did some research and I solve it using the same method they used in angry birds to show the path. What I did was to cast empty gameobjects with the same rigidbody parameters as the bomb and storing their position. Is not the most efficient way but it works. So in your case you could have a pooler of invisible gameobject with same rigidbody as your ball. Than on every update you push a new one of those with the same force and direction as you would push the ball. You have all of this empty objects in the pool so you can easy access theit position. Once ball hits the ground or board or after some time you despawn it. Finally having the positions of each of those you can display something there (i.e. small spheres) or use their positions to draw a line using linerenderers.

//edit one thing you want to make these invisible objects as the parents of your player so when you turn you dont have delay on the tracer.

Also my very first game in unity was a basketball shooting you can find it here https://play.google.com/store/apps/details?id=com.smallbit.basketball&hl=en

Comment
Add comment · Show 5 · 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 Joseph Lerner · May 09, 2015 at 04:34 PM 0
Share

I was going to use your method earlier, but I wanted to learn how to code a more fluid solution. I suppose I could use this method, but there are several problems. In my game you hold down the shot button to increase velocity, so the tracer will need to rise. I guess I could just move the points up and down based on my velocity.

Is there anyway to speed up my prefabs arc? If the prefab moved 1000 times the speed of my basketball, the player wouldn't notice the constant adjustments.

avatar image smallbit · May 09, 2015 at 04:49 PM 0
Share

the problem is in the fact that you cannot know apriori where the ball will go. Alternatively you can implement your own physic system for throw, i.e. trajctory based on gnerated spline, and some gravity system, in that way displaying the ball trajectory would be simple.

In your problem i cannot think of solution that immidiately updates already spawned objects.

avatar image Joseph Lerner · May 09, 2015 at 04:53 PM 0
Share

Yep, I think its best to use a prefab. Trail renders seem to look best right now. I'll see how it works in an hour or so.

avatar image Joseph Lerner · May 09, 2015 at 05:16 PM 0
Share

Trail Renderer looks great, but it doesn't turn correctly when I make it a child of my character. (It bends mid air when I turn, so the line is all zigzaggy) I don't know what I should use. As I said before, if only I could speed up the prefabs flight, the trail renderer would work perfectly.

avatar image Joseph Lerner · May 15, 2015 at 01:18 AM 0
Share

Well, I'm not getting any responses from anyone. I guess I'll accept your answer soon...

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

20 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

Related Questions

Fps Movement Velocity Decrease 0 Answers

RigidBody.MovePosition seems jerky in movement 0 Answers

Limit & Scaling Translation Rate. 0 Answers

Distribute terrain in zones 3 Answers

Gun not smoothly following player,How to make gun smoothly follow player 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