I'm getting a little frustrated :(

I’ve been enjoying the course with it’s different approaches to the same problem but coming from Glitch Garden I’m getting tired of doing an activity to be told that it is not the correct way to do things… then redoing something. A lot of glitch garden was spent with me watching solutions to problems that I did not have in my game but felt I didn’t want to miss anything.

I was here in 3D now, where I belong… No interest in 2D but happy to do my apprenticeship to get the building blocks correct. I’m trying to script where I see redundancy in components linked here an there. I get some of the reasoning but I have my own.

Everything boiled over with me at the start of Bowl Master… I placed the pins accurately and was finally happy but Ben told me I had to rip it all up to add rigid bodies and I will not! I stand my ground here! :slight_smile:

Now I wanted to just loop through the children of the pins blank object and add the bodies in script but all my “Elegant” ideas were thrown away with errors. Can anyone show me a better solution? Should I be sticking to gui components linked (I did a lot of the Glitch stuff scripted this way and had no issues, I was going to script the pins rather than place them but was enjoying messing about in 3D for the first time).

I

private GameObject pinsParent;

        // Use this for initialization
	void Start () {
		pinsParent = GameObject.Find("Pins");
		AddRigidBody (pinsParent.transform);
        }

	private void AddRigidBody(Transform parentPassed)
	{
		foreach (Transform child in parentPassed) {
			child.gameObject.AddComponent<Rigidbody>();
		}

	}

Hi Jerald,

Did you above code example not work?

Yes it worked but I had hoped for better.

  1. I hate Find with a string value, it hurts (like watching someone kick a cat) to use it but my individual pins have that empty Object as a parent.
  2. I will need to set properties on the RigidBody, should I set them before I use the AddComponent?

Anyway I was euphoric having moved to a new dimension and needed to shout out to the World.

I’m using monodevelop at the moment, can I easily just swap it out for VS Code?

Thanks

I hate Find with a string value, it hurts (like watching someone kick a cat) to use it but my individual pins have that empty Object as a parent.

You could create a fairly empty class, name it Pins, attach it as a component to the Pins GameObject, then in code you could use;

void Start()
{
    pins = GameObject.FindObjectOfType<Pins>();
}

I will need to set properties on the RigidBody, should I set them before I use the AddComponent?

You could do something like this;

private void AddRigidBody(Transform parent)
{
    foreach (Transform child in parent) 
    {
        Rigidbody rigidBody = child.gameObject.AddComponent<Rigidbody>();

        // ... set properties on rigidBody
        rigidBody.mass = 1.53f;
    }
}

If there are going to be quite a few properties to set, then I would probably create a separate method and pass the rigidBody in by ref.

Hope this helps.

I’m using monodevelop at the moment, can I easily just swap it out for VS Code?

You can certainly use Visual Studio, from memory VS Code is the light weight version isn’t it? I’ve not tried that personally, but I know Visual Studio Community Edition works fine;

1 Like

Thank you :slight_smile:

Also now have VS Code working with Unity 5 and very happy with it, small footprint, fast and responsive to my sloppy typing.

1 Like

hehe, great stuff. Out of curiosity, are you on a Mac? I thought originally VS Code was only available on Mac, and then later the full version of VS became available also - but I’ve never looked to see if it is actually available on both.

That said, I’m happy with my aging laptop revving up for the community edition, makes me feel like I’m Mavis Beacon when it comes to typing :wink:

VS Code is on windows too. I’ve been using it for a little while now and have found it pretty good. I was having space issues due to VS only installing to the windows install drive but Code lets you install elsewhere so it keeps my SSD happy. There are a few extensions you can install to make it play nice with Unity so there’s no real functionality lost but I do miss the quickly searching Unity docs when hitting ' on a bit of code.

makes me feel like I’m Mavis Beacon

I think I just got PTSD flashbacks from school

1 Like

If it didn’t mean uninstalling and messing around with my setup I might have taken a look, my old laptop would probably breathe a sigh of relief having less to load.

SSD eh, nice… noticeable difference?

I have never yet used the mystical ' character, lol, I recall it being mentioned at the start of the first course and then no end of troubles trying to get it to work… I just type into a browser, with my Mavis skillz… :smiley:

hehe, I recall taking “Pitmans Wordprocessing” at school… I don’t recall what it was on, it certainly wasn’t Office! lol…

:older_man:

Booting into windows yeah there’s a very noticeable difference. For anything without large load times there’s not much change. The only games I’ve ever keep installed on it is EU4 and CK2 due to the long initial loads.

Maybe I should move my unity install there though to deal with my poorly optimised code :thinking: :grin:

I’m sure years of trash talking in BF2 taught me more then Mavis ever has ha

1 Like

Privacy & Terms