And then I've got this OOB stuff and that is out of bounds.
So there's several different versions of this.
But I'm just asking, if I give you a vector 3, is it out of bounds?
Is it outside of this trigger collider that we have?
And then I have 3 more, is it outside in x-direction,
is it outside in the y-direction, is it outside in the z-direction.
And then finally, I have a number I can pass in and the way that this works,
if we are in the local coordinates of this transform for
this box collider here, then if a number is
over 0.5 or under -0.5, then it's out of bounds.
And it's used by all the other ones, this take those numbers and
it turns them into a one if you are out of bounds in the positive direction,
negative one if you are out of bounds in the negative direction and
zero if you are not out of bounds.
And you can see here that I have on 137 and 142 and
147 this transform.InverseTransformPoint(wordPos).
And what this does is it takes a world position point and
puts it into the local coordinates of this transform to scale the BoxCollider.
And that's what makes it such that, if I'm above 0.5, I'm out of bounds.
So you can look at that yourself,
I wanted to show you this awesome, Vector3 extension method.
So I have a new class called Vector3Extensions.
And you can see that this one does not extend modal behavior,
which is totally fine.
95% of the stuff I do extends modal behavior but this one doesn't.
because there's no need to and it would break it.
So Microsoft has documentation that you can see on line 8 there.
Just follow that and take a look at it to learn about extension methods.
But the basic idea is if you have a static class and
a static method in that static class,
you can then create an extension method for an existing class.
So vector three is an existing class.
I can't touch that code but by creating an extension method, I can create a way for
it to look like I've added methods to vector three, and effectively I have.
So you saw before that I add a Vector3.CcomponentDivide as if
this were part of the vector3 class.
And you do that by saying static public vector3 because it's returning a vector3,
you could have return whatever you want.
But proponent divide is the name of that method and then this vector3V0 means
that instead of passing that in as the first parameter after the parentheses and
ComponentDivide, you actually pass that in at the beginning as a vector and
then dot and ComponentDivide.
And then the first thing you pass in in the parenthesis actually becomes v1 here.
And you can see that I've got the math to divide things.
The yellow underline there is that VisualStudio gets annoyed when you try and
compare two floating point values with just equals or
not equals because it's like floating points are inaccurate.
Well, they are, but for zero, they're pretty accurate, and
they're entirely accurate for zero.
And they're entirely accurate for any integer up to about 16 million,
I think, but they are wholly inaccurate for things like one-tenth,
or one-third, because they have to, they're only accurate for
powers of two, going into fractional things.
So that's factor three extensions.
The last thing that we're looking at, finally, is the off-screen wrapper.
You can see, it is on the player's ship, and
it is also on the bullet prefab, so let's take a look at that script.
And that's the last thing for this video.
Here we are, off screen wrapper.