2D CATCH GAME - PT 1

using UnityEngine;
using System.Collections;

public class NetController : MonoBehaviour {

    public Camera cam;
    private Rigidbody2D rb;

    private float maxWidth;

    // Use this for initialization
    void Start ()
    {
        rb = GetComponent<Rigidbody2D>();
        if (cam == null)
        {
            cam = Camera.main;
        }
        Vector3 upperCorner = new Vector3 (Screen.width, Screen.height, 0.0f);
        Vector3 targetWidth = cam.ScreenToWorldPoint (upperCorner);
        float netWidth = renderer.bounds.entents.x;
        maxWidth = targetWidth.x - netWidth;
    }
   
    // FixedUpdate is called once per physics timestep
    void FixedUpdate ()
    {
        Vector3 rawPosition = cam.ScreenToWorldPoint (Input.mousePosition);
        Vector3 targetPosition = new Vector3 (rawPosition.x, 0.0f, 0.0f);
        float targetWidth = Mathf.Clamp (targetPosition.x, -maxWidth, maxWidth);
        targetPosition = new Vector3 (targetWidth, targetPosition.y, targetPosition.z);
        rb.MovePosition (targetPosition);
    }
}

I’m using unity 5 and i don’t understand why my renderer is not being accepted… help?

GameObject’s no longer have a public renderer variable as of Unity 5, you have to get the component manually.

Renderer renderer = GetComponent<Renderer>();

Thank you!!

I’m getting the error above. what does this mean?