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 DevMerlin · Nov 11, 2014 at 03:24 AM · vector3ball

Ball landing point calculation only returns positives?

So I have a landing point calculation for the most part working. However, it's only returning positive numbers...when the ball itself moves both ways, X/-X. The game plays out in X/Y coordinates, with locked Z - this is all 2D.

I know I'm on the right track, but I'd really like it to also return negative coordinates. What am I doing wrong in my code? To be honest, it's probably something really stupid!

 Vector3 BallMinder = BallPosition.position;
 float BallX = BallMinder.x;
 float BallY = BallMinder.y;
 float GroundHitPointX = (BallX + BallY);


Addtional Information: The ball moves by pure gravity and physics. No additional forces are added aside from impacts it may take, which are not coded. X serves as position, Y serves as time until the ground.

Comment
Add comment · Show 3
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 Bunny83 · Nov 11, 2014 at 03:34 AM 0
Share

Uhm, sorry, but that code makes no sense at all. First of all it looks like all you have as input parameters for your "calculation" is a single position of an object. Where is the movement? Next thing is adding the x and y coordinates together doesn't result in any meaningful value.

How is your ball actually moving? Do you use physics or do you move it "manually"? If so post the code that moves / shoots the ball. Without more details we can't help you as the code simply doesn't make sense.

avatar image DevMerlin · Nov 11, 2014 at 03:50 AM 0
Share

I'm a little confused as to why you say it doesn't make any sense. It works. It's all physics-based, the ball drops and is moved by impact. No forces aside from gravity. It is in fact calculating a landing point that is mostly accurate, but it won't provide negative results. Y acts as the time until it takes to hit the ground, X is the current position. BallPosition is.... -should- be obvious. It is the transform.position of the ball in motion.

avatar image Bunny83 · Nov 11, 2014 at 04:29 AM 0
Share

The trajectory of a ball that has an initial speed and experiances gravity (or another linear acceleration) is a parabola. You might be lucky that the position is "mostly accurate" but your formula has no relation to the actual movement. Again you don't even have any movement in your calculations. What do you actual mean by impact? Does that mean the ball hits some kind of slope and bounces to the side? Could you include a screenshot of your setup since your short description doesn't really help what is happening.

(I'm off now, so don't expect an answer anytime soon ^^. I'm back in about 8h)

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

27 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

Related Questions

Player doesn't shoot ball object forward like I tell him 2 Answers

What is the error? 2 Answers

Multiball Situation in Pong 0 Answers

How to set ball velocity after it was hit with a racket in a tennis game? 0 Answers

Using Vector3 with multiple directions 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