Search Unity

Bug Ok Unity's Really Bugged Out This Time

Discussion in 'Scripting' started by Sooly890, Mar 13, 2023.

  1. Sooly890

    Sooly890

    Joined:
    Aug 24, 2022
    Posts:
    107
    Here's my Console:




    Here's the Inspector:




    And here's the code:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using Unityengine;
    4.  
    5. public class camfollow : MonoBehaviour
    6. {
    7.    public Transform target;
    8.    public Vector2 dist;
    9.    public float smooth;
    10.    public Object capule;
    11.  
    12.    private string stringtosearch;
    13.    private float dir;
    14.    private float todir;
    15.    private Quaternion lastangle;
    16.    private Transform targettransform;
    17.  
    18.    void Start()
    19.    {
    20.      
    21.    }
    22.  
    23.    void Update()
    24.    {
    25.        if (target.transform.position.x < 99888)
    26.        {
    27.            targettransform = target.transform;
    28.            transform.position = target.transform.position; //goes to target
    29.        }
    30.        else
    31.        {
    32.            transform.position = targettransform.position;
    33.        }
    34.      
    35.        transform.position += new Vector3(0 - Mathf.Cos(dir * Mathf.Deg2Rad) * dist.x, dist.y, 0 - Mathf.Sin(dir * Mathf.Deg2Rad) * dist.x); //offsets the z and y position by dist
    36.  
    37.        if (Input.GetKeyDown("a"))
    38.        {
    39.            todir += 90;
    40.        }
    41.  
    42.        if (Input.GetKeyDown("d"))
    43.        {
    44.            todir += -90;
    45.        }
    46.  
    47.        dir += (todir - dir)/smooth;
    48.  
    49.        lastangle = transform.rotation;
    50.  
    51.        transform.LookAt(target, Vector3.up); //looks at target
    52.        transform.eulerAngles = new Vector3(0, transform.eulerAngles.y, transform.eulerAngles.z); //resets x rotation
    53.    }
    54. }
    What has happened to Unity?! (It's not the meta data)
     
  2. QuinnWinters

    QuinnWinters

    Joined:
    Dec 31, 2013
    Posts:
    494
    Code (CSharp):
    1. using Unityengine;
    Should be:
    Code (CSharp):
    1. using UnityEngine;
     
    Bunny83 and Ryiah like this.
  3. Sooly890

    Sooly890

    Joined:
    Aug 24, 2022
    Posts:
    107
    I hate case sensitive programming languages
     
  4. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,925
    You shouldn't have to worry about case when a properly set up IDE should have auto-complete to fill out this for you.

    If it isn't, then you should look into fixing that.
     
    Bunny83 and Ryiah like this.
  5. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,188
    Using UnityEngine is part of the base script template, so if you create the script inside Unity it should already have that at the top.
     
  6. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    4,000
    Yep, interesting how people manage to mess this up ^^.