Hello, I have a really fundamental question here.
[RequireComponent (typeof(Ball))]
public class DragLuanch : MonoBehaviour {
private Vector3 dragStart, dragEnd;
private float startTime, endTime;
private Ball ball;
// Use this for initialization
void Start () {
ball = GetComponent<Ball>();
}
public void DragStart ()
//Capture time and position of drag start
{ dragStart = Input.mousePosition;
startTime = Time.time;
for code above,
[RequireComponent (typeof(Ball))]
for this line, I realized that ‘Ball’ means the name of ‘script’ not the name of ‘component’ . I thought it should be name of component but not and was wondering if there’s reason for it?
Second,
private Ball ball;
from this line, Ball is the type of variable ball. I get that, but what is Ball here? meaning that does this mean the script Ball or class Ball? Can you explain me what that line means? and how it links to
ball = GetComponent();
because here Ball is also script name… I am bit confused on fundamental logic here I guess. Let me know! and thank you always.