#Grid Script Doesn't work
1 messages · Page 1 of 1 (latest)
but where does gridVariable come from?
you are doing gridVariable = collier.ClosestPoint(gridVariable);
what is it before that? 🤔
0 I guess
so what does gridVariable = collier.ClosestPoint(gridVariable); do?
I'm not sure at this point
I think it doesn't really do anything but somebody told me I should do it so
the empty?
or the physical grid
the physical grid is actually a bunch of separate planes and I just selected all of them to make it clear
the empty is 1 1 1 but the collider is x30 y20 z15
ok that
first you want to get the apporximated collision position
gridVariable = collier.ClosestPoint(collider.transform.position);
and then
then convert it into the box's local space like you did before with InverseTransformPoint
then you probably need to subtract the box collider's half size from that
so that "back left corner" becomes 0, 0, 0
then round it
how do I do that again
Vector3 localPos = transform.InverseTransformPoint(gridVariable);
and grid variable becomes that
ok
ok
also no. You are working with localPos variable at this point
that's what I got
so is this what you mean
it's what I understood from what you said
ok
Debug.Log("Collided");
gridVariable = collider.ClosestPoint(collider.transform.position);
Vector3 localPos = transform.InverseTransformPoint(gridVariable);
gridVariable = (gameObject.transform.localScale / 2) - localPos;
gridVariable = new Vector3(Mathf.RoundToInt(gridVariable.x), 0, Mathf.RoundToInt(gridVariable.z));
collider.transform.position = gridVariable;
Debug.Log("Ran");```
oh btw
what
you should actually replace
gridVariable = collider.ClosestPoint(collider.transform.position);
with
gridVariable = selfCollider.ClosestPoint(collider.transform.position);
where selfCollider is the box collider of the "empty"
🤦♂️
^
you skip every second message i send
I don't have time to spoonfeed you, good luck
yeah I realized
ykw this isn't worth wasting time on