Crew Sim Hobbling, and OOO

Hey Folks! I managed to get the rest of the AI stuff ported and compiling, and spent most of the day working out the bugs. As of now, it's nearly working as designed:

IMAGE(http://bluebottlegames.com/img/screenshots/screenshot-2016-01-19.jpg) Two men enter. One man gets food. The other sleeps.

Surprisingly, the biggest issue I'm running into seems to be null pointers from not initializing various things. I think the way Unity calls Start() and Update() is not the way I think they are called. Namely, Update() seems to be called arbitrarily before Start() on my classes, and I'm finding I need to do a lot of hand-holding to make sure each class is initialized before it's operated on. Probably, I just need to roll my own initialization and update code, and call them manually.

We're not quite at the point where AI is interacting with each other, grabbing food, etc. However, the AI is wandering around the ship, and periodically checking against its own priorities for what to do next. The next thing I need to fix is this decision code so there are no null pointers.

It's sort of implied above, but this all takes place in a new game mode called "CrewSim," as opposed to "ShipEdit" where the ship parts are arranged and saved. I managed to get these modes to talk to each other, so one can build a ship, switch to crew sim mode, watch stuff, and switch back to continue editing the ship.

This sort of mode-changing is something I hadn't done before in Unity, and it wasn't too hard. It also forced me to clean up the organization of more code, so it lives in more logical places when it needs to be shared between modes.

Not too shabby! I'll have to sort out that AI decision stuff next, and see where the simulation stands!

Out of the Office

Also, I'm afraid I'm going to be out of the office again. Sorry about that. More immigration stuff for Rochelle, inconveniently not local to us. The plus side is we'll at least be seeing my family while there, which doesn't happen often due to their distance from us.

Anyway, I'll be trying to work on the road again, but internet access may be spotty along the way. I should be back to normal on the 29th. (Until immigration's next trick whisks me away, I guess.)

Have a good weekend, all. And see you when I return!

Comments

mrlinds's picture
mrlinds

Awake might be what you need instead of Start.
http://docs.unity3d.com/Manual/ExecutionOrder.html has a good map of what happens when.
Lots of issues with life-cycle though.
OnDestroy/OnDisable can be a pain too

<br>

Magi's picture
Magi

The bed seems to be a bit too long, or is everyone 2 meters tall? haha

The Science&Sorcery Mod deal with nanobots. travel to the astral realm.

dcfedor's picture
dcfedor

@mrlinds, ah, yes. Awake was the key, thanks! Weird how the class templates for Unity all say use Start() to initialize when Awake() seems more appropriate.

@Magi, yes, yes, the beds are too tall :) Placeholder art!

Dan Fedor - Founder, Blue Bottle Games

Malacodor's picture
Malacodor

Beds can never be too big!

Ran around with a clown mask before it was cool