Getting Object Data From RayCasts
Posted: Fri Oct 21, 2011 12:53 am
Hi,
I was wondering if anyone could give me some information about how to use the HitObject gained from a RayCast. My code looks like this so far:
So I know that I can use HitObject to get some information about the object that was hit by the ray. What I would like to know is how to actually access that object using HitObject. For example, I have a Door class which inherits from the Box class, and I would like to call the Door's Open function when it gets hit by the ray. However, I can't find any way to actually cast the HitObject to get to the Box class, let alone my class. Is there anyway I can use this data to convert the HitObject to the Door it hit? Or is there anyway to compare information so I can at least check to see whether the Door and HitObject correspond?
Also, as a sidenote: I'd like to store a string about the collision entity in its tag. I was able to get this to work for a static mesh, but in my Door class (which inherits from a
class I wrote for drawing a box which subsequently inherits from the Box class itself) the data doesn't seem to be getting through. Does anyone have any thoughts as to why this doesn't work?
EDIT: A second side question. Is the help file on the Bepu codeplex page broken? When I try to view anything in it the link is broken.
I would really appreciate any help here.
I imagine there has to be some way to check which Door was hit, if it's not possible to access the Door itself.
I was wondering if anyone could give me some information about how to use the HitObject gained from a RayCast. My code looks like this so far:
Code: Select all
space.RayCast(new Ray(character.Camera.Position + character.Camera.Direction * 10f, character.Camera.Direction), 10f, out result);
if (result.HitObject != null)
{
}
Also, as a sidenote: I'd like to store a string about the collision entity in its tag. I was able to get this to work for a static mesh, but in my Door class (which inherits from a
class I wrote for drawing a box which subsequently inherits from the Box class itself) the data doesn't seem to be getting through. Does anyone have any thoughts as to why this doesn't work?
EDIT: A second side question. Is the help file on the Bepu codeplex page broken? When I try to view anything in it the link is broken.
I would really appreciate any help here.
