Quantcast
Channel: Answers by "Mortoc"
Viewing all articles
Browse latest Browse all 73

Answer by Mortoc

$
0
0
If you keep track of your "wall" or plane as point-normal, it's really easy ([Khan academy link for the math involved][1]). The code would look something like this: Vector3 wallToObject = wall.position - object.transform.position; float dot = Vector3.Dot(wallToObject, wall.normal); if( dot > 0.0f ) // object has passed the wall this frame, move it back and instantiate your collision object [1]: https://www.khanacademy.org/math/linear-algebra/vectors_and_spaces/dot_cross_products/v/defining-a-plane-in-r3-with-a-point-and-normal-vector

Viewing all articles
Browse latest Browse all 73

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>