I’m afraid you can’t do that, Dave

Errors are an annoying thing to deal with. Unfortunately, they are also something that pops up irrespective of whether or not you want them to.

In particular, the scripting for the movement of my train was particularly error prone. If it did something, it wouldn’t do something else, and so on. However, I believe this problem has now been mostly solved.

In the initial version of the movement script, the train movement was determined by a spherical sensor coming form the train. And while it worked well for testing purposes, it was inherently difficult to work with. In addition to that, it also had a tendency to not detect some items around it. However, I managed to eventually fix the problems, by changing the way the script found the closest object.

The first version wrote the data about the detected objects to an array. The new version works in a similar way, but with extra functionality. Namely, it writes all objects with a particular tag to an array, then finds what one is closest to the train. In order to prevent reversal, the script also assigns a new tag to the objects it has passed across, which removes them from the array. The spherical sensor still plays an active roll, but in a less important way – now, it only gets used to determine whether or not the train is at the end point.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s