Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Game Development

Hudson Cordova
Hudson Cordova
115 Points

Error! NEED HELP PLEASE!

Hi I really need help with my unity game. I need to fix these errors with this code:

Here are the errors that go to the console:

1

Assets/Standard Assets/Cameras/Scripts/TargetFieldOfView.cs(73,34): error CS1525: Unexpected symbol{', expecting )',,', ;',[', or ='

2

Assets/Standard Assets/Cameras/Scripts/TargetFieldOfView.cs(80,1): error CS8025: Parsing error

using System; using UnityEngine;

namespace UnityStandardAssets.Cameras { public class TargetFieldOfView : AbstractTargetFollower { // This script is primarily designed to be used with the "LookAtTarget" script to enable a // CCTV style camera looking at a target to also adjust its field of view (zoom) to fit the // target (so that it zooms in as the target becomes further away). // When used with a follow cam, it will automatically use the same target.

    [SerializeField] private float m_FovAdjustTime = 1;             // the time taken to adjust the current FOV to the desired target FOV amount.
    [SerializeField] private float m_ZoomAmountMultiplier = 2;      // a multiplier for the FOV amount. The default of 2 makes the field of view twice as wide as required to fit the target.
    [SerializeField] private bool m_IncludeEffectsInSize = false;   // changing this only takes effect on startup, or when new target is assigned.

    private float m_BoundSize;
    private float m_FovAdjustVelocity;
    private Camera m_Cam;
    private Transform m_LastTarget;

    // Use this for initialization
    protected override void Start()
    {
        base.Start();
        m_BoundSize = MaxBoundsExtent(m_Target, m_IncludeEffectsInSize);

        // get a reference to the actual camera component:
        m_Cam = GetComponentInChildren<Camera>();
    }


    protected override void FollowTarget(float deltaTime)
    {
        // calculate the correct field of view to fit the bounds size at the current distance
        float dist = (m_Target.position - transform.position).magnitude;
        float requiredFOV = Mathf.Atan2(m_BoundSize, dist)*Mathf.Rad2Deg*m_ZoomAmountMultiplier;

        m_Cam.fieldOfView = Mathf.SmoothDamp(m_Cam.fieldOfView, requiredFOV, ref m_FovAdjustVelocity, m_FovAdjustTime);
    }


    public override void SetTarget(Transform newTransform)
    {
        base.SetTarget(newTransform);
        m_BoundSize = MaxBoundsExtent(newTransform, m_IncludeEffectsInSize);
    }


    public static float MaxBoundsExtent(Transform obj, bool includeEffects)
    {
        // get the maximum bounds extent of object, including all child renderers,
        // but excluding particles and trails, for FOV zooming effect.

         var renderers = obj.GetComponentsInChildren<Renderer>();

        Bounds bounds = new Bounds();
        bool initBounds = false;
        foreach (Renderer r in renderers)
        {
            if (!((r is TrailRenderer) || (r is ParticleSystem) || (r is ParticleSystemRenderer)))
            {
                if (!initBounds)
                {
                    initBounds = true;
                    bounds = r.bounds;
                }
                    else 
                {
                    bounds.Encapsulate(r.bounds);
                               }       temporary variable
                {
            {
        float max = Mathf.Max(bounds.extents.x, bounds.extents.y, bounds.extents.z);
                return max;
    }

}

}

1 Answer

Quinn Rodgers
Quinn Rodgers
9,561 Points

Hi, it looks like you might have too many '{'. Are you able to check that your opening braces match with the closing ones.

Look around the bounds.Encapsulate. Also, the temporary variable line on the follow line looks a little out of place. If it is a comment add the //. Hope that helps.