|
I'm trying to figure out a way of casting rays for the sides of my player (character controller.) It's easy enough to fire a ray from the center, but for this particular task I need to be able to fire from the left and right sides of the players bounds. I thought it would be relatively easy to get the width of the player gameObject and fire the ray from there (offset it from the center) but it seems it isn't nearly as easy I thought. Am I missing something?
(comments are locked)
|
|
If you have the width, can you not just use that to create a temporary object at that distance either side of the centre, fire the ray from that and then delete it? Or alternatively keep the objects there to save re-creation, depending on how often it needs calculating. I don't have the width as far as I know. It isn't a property of Transform.
Aug 07 '10 at 06:40 PM
Disaster
Ah, apologies, so you said. Try using mesh.bounds.extents.x
Aug 09 '10 at 06:37 PM
Novodantis 1
where var mesh : Mesh = GetComponent(MeshFilter).mesh;
Aug 09 '10 at 06:41 PM
Novodantis 1
(comments are locked)
|
|
I haven't tested this code but I think this method should work,
(comments are locked)
|
