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 /
avatar image
0
Question by ChrisUOB · May 14, 2019 at 09:22 PM · objectcollision detectiontriggersplane

How to mark collision point of plane and object?

Hi,

I am trying to create a Virtual Reality game to measure how people intercept objects by tracking their eye movements with the FOVE VR headset. I am also using a Phantom Haptics device which has allowed me to restrict participants field of movement to a certain area, constrained to the X and Y axes. I have been trying to write a script that displays the point where the ball passes through the plane that participants are restricted to so that participants can see how close they were to catching the object but have had no success as of yet. I read somewhere that using custom physics in Unity can cause issues with registration in situations like this. Below is the code used to calculate the ball trajectories. I did not write this code as I am carrying on from someone else's work and am fairly new to programming. So, basically what I would like to know is: is there any code or procedure that could help me display the interception point of the plane and ball and then disappear a second later, each time the ball passes through a plane? Or is the custom physics perhaps breaking the object detection? I have been using OnTriggerEnter but have not been able to get anything to happen at all. Sorry for the long post and thank you for any help.

    public void launchBall(Vector3 targetPoint, Vector3 startPoint, float initialVelocity)
     {
         float g = -Physics.gravity.y;
 
         if (useTrajectory)
         {
 
             ball.transform.position = startPoint;
             ball.useGravity = true;
             ball.velocity = calculateTrajectory(targetPoint, startPoint, initialVelocity);
         }
         else
         {
             gameObject.transform.position = new Vector3(0, 0, 5.0f);
             ball.velocity = new Vector3(0, 0, 0);
         }
 
     }

     Vector3 calculateTrajectory(Vector3 target, Vector3 startPoint, float v0)
     {
         float t_x = target.x - startPoint.x;
         float t_y = target.y - startPoint.y;
         float t_z = target.z - startPoint.z;
         float g = -Physics.gravity.y;
 
         float theta = Mathf.Atan(
                     (Mathf.Pow(v0, 2) -
                     Mathf.Sqrt(Mathf.Pow(v0, 4) -
                     g * (g * Mathf.Pow(t_z, 2) + 2 * t_y * Mathf.Pow(v0, 2))))
                     / (g * t_z)
                     );
 
         float v_z = -v0 * Mathf.Cos(theta);
         float v_y = -v0 * Mathf.Sin(theta);
         float vst = v0 * Mathf.Sin(theta);
         float tInf = (v_y + Mathf.Sqrt(Mathf.Pow(v_y, 2) + 2 * g * (-t_y)))
             / g;
 
         float v_x = t_x / tInf;
 
         return new Vector3(v_x, v_y, v_z);
 
     }
 }
 




Comment
Add comment · Show 1
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 Pangamini · May 14, 2019 at 09:34 PM 0
Share

Does your moving object has a rigidbody attached? Otherwise triggers or collisions won't work

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by ChrisUOB · May 14, 2019 at 10:03 PM

Thanks for your reply, @Pangamini. I do, I also have sphere collider on the moving object and a mesh collider on the plane. I have also created a practice project to practice working with triggers, in which I have moved a ball through a plane using a simple controller, and displayed a message in the log OnTriggerEnter which works just fine for my practice project. However, when I try and apply the same idea to my main project, nothing happens when the ball passes through the plane.

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

116 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

Related Questions

Player is only detected in trigger when moving 2 Answers

Trigger implementation 1 Answer

Bouncing the ball off a collider and destroying it using trigger 0 Answers

How to single out specific colliders from another object 1 Answer

How do I prevent multiple triggers using OnTriggerEnter? 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