Hi, i try to create this but i have a problem when the boxCollider has a oblique position.
I create the first wall and it has a boxCollider for all the length on one side.
I create another wall and it has a sphere in one angle with sphereCollider, rigidBody and script with OnCollisionEnter ...Exit.
This sphere follows my mouse with raycastHit and when sphere collide with boxCollider i use this code:
if (...)
{
targetPos = new Vector3(myFw.raycastHit.point.x, myFw.raycastHit.point.y, myCollisionTarget.collision.gameObject.transform.position.z);
gObjPvtOrigin.transform.LookAt(targetPos);
}
If my wall it has the rotation.y = 0 the horizontal snap, works very well...but the oblique and vertical have a problem (because targetPos it has only collision.position.z)...
How do i create a snap with oblique boxCollider?
I would like that my mouse, moved the wall along boxCollider, without problem if the box is vertical horizontal or oblique....
Please help me thanks!!
↧