Debug.Log in start gets triggered twice.

using UnityEngine;
using System.Collections;

public class asteroidMove : MonoBehaviour {
    Vector3 MoveTo;
    float _currSide;
    Vector3 _startPos;
    GameObject Asteroid;
    bool final = false;
    int _sideStarter;

    void Start() {
        _sideStarter = (transform.position.x == -200) ? 1000 : -200;
        MoveTo = new Vector3 (_sideStarter, 0, Random.Range (-100, -700));

        Debug.Log(_sideStarter);
        Debug.Break ();
    }

    void FixedUpdate() {
        if (final) {
            Debug.Log ("Found! Going to: " + MoveTo);
            Instantiate (new GameObject ("Going to"), MoveTo, Quaternion.identity);
            Debug.Break ();
        }
    }
}

I’ve gathered that certain people who load their application have problems with that, and managed to fix it. But my “application” involves 0 LoadLevel instances. The Debug is triggered twice:
-200
UnityEngine.Debug:Log(Object)
asteroidMove:Start() (at -----/asteroidMove.cs:16)
Any grand ideas?

Check to see if you have this script on 2 objects by accident.

You can change it to Debug.Log(_sideStarter, this); Then click on each debug message. It’ll flash-highlight each object the debug message came from.

2 Likes

Ah, indeed, there was a second object, also, this, so good to know that that exists. You couldn’t just guess how often I would like to know which of the doofers sets off the info.

Problemo fixo. (sorry Spanish, Latin and Italian people)

I almost always add ‘, this’ to my Debug.Log calls just out of habit. It never hurts to have a reference to where it came from, and occasionally it saves the day.

1 Like