Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Question Movement

Discussion in 'Scripting' started by junior333istall, Jan 17, 2023.

  1. junior333istall

    junior333istall

    Joined:
    Jan 11, 2023
    Posts:
    101
    i dont understand what this error message means and im trying to add movement, the code hasnt changed but hwne i went to add something it gave me this error. i ctrl z but it still didnt work. What do i do?

    upload_2023-1-16_21-2-33.png


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class EnemyMovement : MonoBehaviour
    6. {
    7.     public float moveSpeed;
    8.     public Rigidbody2D rb2d;
    9.     // Start is called before the first frame update
    10.     void Start()
    11.     {
    12.         rb2d = GetComponent<Rigidbody2D>();
    13.     }
    14.  
    15.     // Update is called once per frame
    16.     void Update()
    17.     {
    18.         rb2d.velocity = Vector2.left * moveSpeed;
    19.     }
    20. }
    21.  
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,938
    You seem to have two scripts called the same thing. You probably have accidentally duplicated your script.
     
  3. junior333istall

    junior333istall

    Joined:
    Jan 11, 2023
    Posts:
    101
    is it possible to have different consoles for different debug logs? i have multiple debug logs throughout my script but they all go through the same console and you can see whats happening rlly so ye
     
  4. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,938
    Is this related to the above problem?

    Read the docs on Debug.Log so you can see that there's a second parameter that lets you give the log entry context: https://docs.unity3d.com/ScriptReference/Debug.Log.html
     
  5. AngryProgrammer

    AngryProgrammer

    Joined:
    Jun 4, 2019
    Posts:
    435
    As my predecessor wrote. You have two scripts/classes with the same name. If you want to keep both, use namespace on one.

     
  6. Juice-Tin

    Juice-Tin

    Joined:
    Jul 22, 2012
    Posts:
    233
    there is only 1 console but the link spiny199 gave:
    https://docs.unity3d.com/ScriptReference/Debug.Log.html

    Also shows how to set the color of logs, this makes it easier to see different ones.