![]() ![]() That's very effective at forcing 2D movement. To prevent an object moving on the z-axis you can either attach a physics joint to the object or you can just add a line in function FixedUpdate that sets the z position and velocity to 0. Or in the example you've given, the normal would be (0,-1,0) and if you bullet is traveling upwards at 45 degrees its velocity might be (-2,2,0) and after the reflection it'd be moving at (-2,-2,0)īut yeah, use colliders and rigid bodies and let the physics engine sort it out. ![]() v is reflected off of the surface, and gives a reflection vector v' which is used as the new velocity of the object. Where '*' is the scalar multiplication operator, '.' is the dot product of two vectors, and '-' is the subtraction operator for two vectors. Use raycast from the bullet to find the normal of the surface that's going to be hitīasically if you have a vector v, which represents the object's velocity, and a normalized normal vector n, which is perpendicular to the surface with which the object collides, then the new velocity v' is given by the equation:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |