|
Is this behaviour of Physics.SphereCast correct? I mean, it seems that SphereCast casts starting from the circumference, not the center of the sphere. For example if you add a sphere to a game object and try this code
you obtain this result:
Since i want to find all the contact points of a sphere (without using a collider) is there a way to do this using spherecast? To be clear, i want to do something like this: http://newtondynamics.com/forum/viewtopic.php?f=14&t=5999 UPDATE 11/10/2010 corrected the esposition
(comments are locked)
|
|
There are several things wrong with this question:
Whatever it is that you consider "expected behaviour" seems to be mistaken. Perhaps you should explain what it is that you expect to happen. A sphere of radius 0.5 cast a distance of 0.5 in a direction should hit any colliders whose exteriors are positioned between position 0.5 and 1.0 on that axis and whose exteriors are facing the object. This is what your spherecast is doing: I explain better what i want to do. I want to use spherecast to check if a sphere collide with anything. So this is what i do: 1)add an empty game object 2)add a sphere collider with isTrigger checked (radius 0.5 center (0,0,0) so pivot coincide with the center of the tranform). the collider is not used,its just to have a visual repr. of the sphere 3)add the code above 4)I expect that i can check if the sphere collides with anything via the various onGroundDown, onGroundLat, onGroundFront. But it doenst work.its like the spherecast is always "shifted" respect the sphere collider.
Nov 10 '10 at 01:58 PM
michele
A spherecast will sweep a sphere through 3D space. That's what the distance parameter is for. You are providing a distance of radius so it will sweep radius units in the direction that you provided. If you didn't want it to sweep, you could provide a distance of 0, but why use Spherecast in this case? If you don't want it to sweep, why not just use OverlapSphere or CheckSphere?
Nov 10 '10 at 04:44 PM
skovacs1
I do want to do a sweep test. Im using the spherecast to find all the contact points of a wheel, for this reason im using a spherecast (raycast doesnt find all the contact point). So i put the wheel at the center of the transform and i do a spherecast from the center of the transform with radius the radius of the wheel (and lenght of the sweep radius). So I EXPECT that with onGroundDown, onGroundLat, onGroundFront i can find all the contact point of the wheel, but it always casts starting from the circumference, not the center of the sphere.
Nov 10 '10 at 08:49 PM
michele
Spherecast does a sweep because that's what it's supposed to do. As I said before, if you do not want a sweep, then you shouldn't provide it a sweep distance when you call it. It does not cast starting from the circumference! It starts from the center you passed in and then sweeps a sphere of the radius you passed in by the distance you passed in along the direction you passed in because that's what a spherecast is.
Nov 12 '10 at 03:33 PM
skovacs1
If your problem is that your tire is already in contact with the ground when you cast and the cast is not picking up the contact, you should consider passing spherecast a radius that is slighly smaller than your tire so that the ground is not already inside of the sphere that is being cast.
Nov 12 '10 at 03:34 PM
skovacs1
(comments are locked)
|

