#### Archived

This topic is now archived and is closed to further replies.

# moving camera parallel to walls

This topic is 5894 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I've written a damn simple collision detection function to work with quads. At the moment if the user tries to move the camera in a direction which will result in the camera being "too close" to a polygon in the level, then the move is disallowed. However what I want to do is to allow the user to move in this case, parallel to the offending polygon. The amount that they move parallel to the polygon will be scaled by the angle between the way they want to go and the vector parallel to the polygon. OK so assuming that I can find the vector parallel to the polygon I would use
newVectorForward = dot(OriginalVectorForward,ParallelVector)*ParallelVector

To find this vector, will it work to use the cross product of the Y-axis vector and the normal of the plane of the polygon? If anyone has done this, some advice would be really appreciated. Thanks Toby Gobsmacked - by Toby Murray [edited by - tobymurray on April 29, 2002 10:55:21 PM]

##### Share on other sites
What you want to do is this:

newVector = scaleFactor * ( moveVector - quadnormal*( dot(quadnormal, moveVector) ) )

From the basics:
dot(quadnormal, movevector) = "length" of projection of moveVector onto quadnormal (assuming unit-length qn)

We subtract out the perpendicular part of mV, which is the part we just projected onto qn, to get newVector in the plane of the quad, and multiply by a scale factor dependent on how we want to relate the initial and final vectors. In the simplest case,
scaleFactor is equal to length of moveVector divided by length of newVector.

HTH,
ld

• 35
• 12
• 10
• 9
• 9
• ### Forum Statistics

• Total Topics
631358
• Total Posts
2999531
×