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 michele · Nov 09, 2010 at 08:02 PM · transformcentershift

Physics.SphereCast problem? center of SphereCast different from center of its transform

Anyone has expererienced this problem with Physics.SphereCast? I mean, it seems that the center of SphereCast is different from the center of its transform.

if you add a sphere collider to a game object and try this code the behaviour is not the expected behavior (SphereCast doesn't return true when you expect, its like the spherecast is shifted):

using UnityEngine;

public class test : MonoBehaviour {

public bool onGroundDown=false; public bool onGroundLat=false; public bool onGroundFront=false; public SphereCollider sphereCollider; RaycastHit hitdown; RaycastHit hitlat; RaycastHit hitfront;

void FixedUpdate(){ onGroundDown=Physics.SphereCast(transform.position, sphereCollider.radius, -transform.up , out hitdown , sphereCollider.radius); onGroundLat=Physics.SphereCast(transform.position, sphereCollider.radius, -transform.right , out hitlat, sphereCollider.radius); onGroundFront=Physics.SphereCast(transform.position, sphereCollider.radius, -transform.forward , out hitfront , sphereCollider.radius); } }

instead with this code it works like expected:

using UnityEngine;

public class test : MonoBehaviour {

public bool onGroundDown=false; public bool onGroundLat=false; public bool onGroundFront=false; public SphereCollider sphereCollider; RaycastHit hitdown; RaycastHit hitlat; RaycastHit hitfront;

void FixedUpdate(){ Vector3 sphereCenter=new Vector3(transform.position.x+sphereCollider.radius,transform.position.y+sphereCollider.radius,transform.position.z+sphereCollider.radius);

onGroundDown=Physics.SphereCast(sphereCenter, sphereCollider.radius, -transform.up , out hitdown , sphereCollider.radius); onGroundLat=Physics.SphereCast(sphereCenter, sphereCollider.radius, -transform.right , out hitlat, sphereCollider.radius); onGroundFront=Physics.SphereCast(sphereCenter, sphereCollider.radius, -transform.forward , out hitfront , sphereCollider.radius); } }

Is this behavior wanted or is an error of SphereCast?

UPDATE 11/05/10 IS it possible that anybody can help me with this problem? Its a week that this question is still open.

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 skovacs1 · Nov 09, 2010 at 08:20 PM 0
Share

This is a duplicate of (http://answers.unity3d.com/questions/25603/physics-spherecast-problem-center-of-spherecast-different-from-center-of-its-tra) Please do not duplicate questions. If you are not getting any answers, consider ins$$anonymous$$d revising your question.

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

No one has followed this question yet.

Related Questions

SphereCast casts from the circumference, not the center of the sphere 1 Answer

Group objects, and center to parent GameObject, but keep relation to eachother 0 Answers

How to change a prefab's pivot point to exactly its center? 0 Answers

How do I offset the scaling center for a cube 1 Answer

Finding the center of several GameObjects 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