Creating a new vector along a known vector in the opposite direction of the known vector.
I'm trying to figure out how to create a vector that is along the path of a game object's contact point normal vector. My goal is to have a camera that points at the game object and is direclty "above" this game object in relation to the contact point between said game object and another game object.
I'm able to obtain the normal vector and use this to apply a force in the opposite direction of the normal and am able to roll a ball up a wall using this method - so I know the normal vector is correct. However, I want to have a camera that follows the ball as it rolls on the wall using this normal vector as a reference.
Here is the code I've come up with but does not work how I thought it would. This is only one of several attempts.
//targetGO is the gameObject I want to focus on
//transform.position is the position of the camera game object transform
//climbingCameraHeight is the distance I want the camera
//to be away from the normal contact point.
//collisionNormal is the normal vector of the contact point between targetGO and a collider
transform.position = targetGO.transform.position;
transform.Translate(collisionNormal * climbingCameraHeight);
transform.LookAt(targetGO.transform);
Here is a picture showing what I'm trying to accomplish:
Answer by vvvultures · Aug 22, 2020 at 07:36 PM
Based on your diagram... Take the normal vector and multiply it by -1 to get your desired vector. To get the desired co-ordinate, set the magnitude of the normal vector to 10, then add it to the position vector of the contact point to get the blue point. You can confirm this by adding your desired vector + the magnitude to your desired point.
Since this was posted in 2017 I'm assuming you've solved your issue but hopefully someone else finds this useful ;)
Your answer
Follow this Question
Related Questions
Spotlight Direction 2 Answers
Find Normal Vector to BoxCollider 0 Answers
Rotate the point around the normal from two points (flip point) 2 Answers
Cant Get a Bullet to Shoot (C#) 2 Answers
Split string into three pieces? 1 Answer