Question by
Ahsenhein · Mar 06, 2017 at 10:54 PM ·
cameratransform.positioncamera followinversetransformpoint
Camera rig - tanks tutorial - local and world space?
I'm really confused about this function so I'll be making a question right next to each line of code that I didn't get.
Link to the video tutorial:
https://unity3d.com/pt/learn/tutorials/projects/tanks-tutorial/camera-control?playlist=20081
Start at 22:42.
private float FindRequiredSize()
{
Vector3 desiredLocalPos = transform.InverseTransformPoint(m_DesiredPosition); //What's the difference between local and world space? Does that mean I'll get the coordinates(x,y) on my screen based on my world coordinate?
float size = 0f;
for (int i = 0; i < m_Targets.Length; i++)
{
if (!m_Targets[i].gameObject.activeSelf)
continue;
Vector3 targetLocalPos = transform.InverseTransformPoint(m_Targets[i].position); //Am I incrementing or just replacing it with the last targets.position that I got from the loop?
Vector3 desiredPosToTarget = targetLocalPos - desiredLocalPos; //?
size = Mathf.Max (size, Mathf.Abs (desiredPosToTarget.y)); //?
size = Mathf.Max (size, Mathf.Abs (desiredPosToTarget.x) / m_Camera.aspect); //?
}
size += m_ScreenEdgeBuffer;
size = Mathf.Max(size, m_MinSize);
return size;
}
Comment
Your answer
Follow this Question
Related Questions
Fixed Camera rotate to follow player 2 Answers
Trying to turn the Tank Game Camera script into perspective projection. 1 Answer
Beginner orbit camera + player rotation issues 1 Answer
How do you get the X and Z position of the map, which is in the center of the screen? 1 Answer
Spyro Like Camera Follow 0 Answers