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 oliver-jones · Jun 30, 2011 at 03:54 PM · physicsraycastcastcapsule

Physics.CapsuleCast Help

Hello,

I've been using the Physics.Raycast to cast where my mouse position is, relevant to the scene (Camera.main.ScreenPointToRay).

But the Raycast is too precise, and so I want to try and introduce the CapsuleCast, but I am having a few problems trying to replace it.

This is what I am trying to achieve :

125alt text125

Here is my old Raycast:

 var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
 var layerMask = 1 << 14;

 if (chooseLocation) {
         layerMask = ~layerMask;
         Physics.Raycast (ray, hit, 900, layerMask);
         Debug.DrawLine (ray.origin, hit.point);
         dummyObj.Translate((Vector3(hit.point.x, dummyObj.position.y, hit.point.z) - dummyObj.position)); // * Time.deltaTime *followSpeed
         currentHit = hit;
         CustomCurser.showOriginal = false;
 
     }

And I'm just simply trying to convert this to work with the CapsuleCast:

    var ray = Camera.main.ScreenPointToRay (Input.mousePosition); //-hit-
    var layerMask = 1 << 14;
         
         if(debugClick){
             layerMask = ~layerMask;
             var p1 : Vector3 = transform.position;
             var p2 : Vector3 = p1;
             Physics.CapsuleCast(p1, p2, 10, ray.origin, hit, 10);
             Debug.DrawLine (ray.origin, hit.point);
         }

I'm not 100% sure on what I'm suppose to do with the p1 and p2 - What I'm trying to get is for a capsule to raycast on down on anything on my scene that the mouse position is over with a radius of 10.

Would appreciate any help with this.

Thanks

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 oliver-jones · Jul 01, 2011 at 11:49 AM 0
Share

All I want is to make the raycasts width a bit wider.

1 Reply

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

Answer by jonas-echterhoff · Jun 30, 2011 at 03:58 PM

Try

Physics.SphereCast (ray, 10, hit, 900, layerMask);

Comment
Add comment · Show 16 · 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 oliver-jones · Jun 30, 2011 at 04:00 PM 0
Share

is there a way I can do a Debug.DrawLine for the whole sphere?

avatar image oliver-jones · Jun 30, 2011 at 05:02 PM 0
Share

This doesn't seem to be doing the job

avatar image Waz · Jul 01, 2011 at 12:07 PM 0
Share

It should work. Note that this is a replacement for your original Raycast, not your capsule cast. Note that the shape of a SphereCast is a capsule (obvious when you imagine it).

avatar image PrimeDerektive · Jul 01, 2011 at 12:59 PM 0
Share

Note that a SphereCast is shaped like a long, sideways capsule... but a CapsuleCast is shaped like a long "bar" of sorts with upright capsules on the "ends", which might be what he really want (like if his trying to do a check if a capsule collider will fit in a space, SphereCast is probably not what he wants).

avatar image oliver-jones · Jul 01, 2011 at 01:44 PM 0
Share

@Derek Traver - that is exactly what I want, how would i go about doing that?

Show more comments

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Why does CapsuleCast appear in the wrong place? 0 Answers

The CapsuleCast is broken. 0 Answers

Physics.SphereCastAll with triggers 1 Answer

AddForce to a point of a GameObject, not the center 1 Answer

HOW DO I USE RAYCASTHIT 2D???? 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