- Home /
Parameterising one axis of collider - projecting extents not quite working.
So, I'm trying to create what is essentially a "bump map" for my ground colliders. Basically, instead of a complicated collider, I'm just using an AnimationCurve to specify "bumpiness", and offsetting my collisions based on that. This works, but my issue is in parameterising the collider such that I can read off a 0-1 float value depending on the position within the bounding box. Now, my code so far is this:
Bounds b = collider.bounds;
return bumpiness.Evaluate(MagnitudeAlongDirection((point - b.min), Vector3.Project(b.max-b.min, transform.forward)))-1;
MagnitudeAlongDirection is a custom-defined function that calculates the magnitude of a vector along a specific direction (for example, if the two vectors have the same magnitude, and the same direction, it returns 1, if one of them is facing backwards, and is half the magnitude, it would return -0.5, etc.)
My issue here is that the parameterisation doesn't seem to cover the entire collider. I've tried drawing a ray of the parameterisation, and this is what it looked like:
You can see from this that the white line stops short of both ends of the collider, where it should, I think, just overshoot both ends (since the collider is at an angle). Can anyone help me work out what is wrong here?
Answer by Hoeloe · Sep 03, 2013 at 05:29 PM
I solved this with an alternative method. I created a custom editor with some sliders and handles that would allow me to position the end points of the parameterisation manually. This way, I can customise the "bump mapping" more accurately, and with an approximate to the curves drawn on the editor, I can position the map perfectly for what I need.