Mar 19

Player controller.
1,2,3 switches control mode.
1: FPS style. asdw/arrows for movement and mouse for looking.
2: Third person view. asdw/arrows for movement and looking.
3: Top down view. Same as above.
2,3: Raisable camera with mouse scroll wheel.

Switch pad with button. Walk on it to trigger the movable platform. Alternatively push the box onto it, so you can jump up on the platform. The movement script for the platform is … bad. Too be continued.

Web version of the project. (Requires Unity3D Web Player)

Mar 19


So I wanted to use an interface reference as a public variable, but it wouldn’t show up in the inspector. After many hours researching and trying different things, I finally settled for using abstract classes instead, and using the unity way of adding scripts to objects as my interface.

I made a pad with a button on it. This button is my switch. When something (player or box) moves onto it, it should trigger an event in another target object. So I wanted to have a SwitchTrigger interface for the target of my switch object.

What I did instead was the following:

Then I have to create an explicit class inheriting this abstract class for the specific GameObject I want it on.

I then add the script SwitchTriggerTarget to my MovingPlatform object.

MovingPlatform object also has a MovingPlatform script, which basically just makes sure other objects on MovingPlatform object follows it when it moves. This is done by parenting.

The platform movement is done by another script. Just add the modules you want onto the GameObject, and then make a prefab of it. Modular and nice.

Now, my SwitchPad (the one you walk on to trigger the button), looks like this.

The highlighted row: By using the abstract class as the type, only GameObjects with scripts inheriting from SwitchTarget, like MovablePlatformSwitchTarget, can be dragged onto the target in the inspector.

This works, but everything would have been easier if an interface could be used as type and shown in inspector…

Mar 18

I recently found Unity and fell in love. I have been playing with it for a few days now and have started on a game. I like how modular you can make everything with the scripts you attach to the objects.

I hope anyone reading will help if I do something in a bad way, and hopefully somewhere along the ride I can help someone else with my scripts.

I have experience in C, C++, Java, Javascript, but not C#. Although, I am going for the C# route, since it seems like the better way to go.

The game will be a Mario 3D type of game. Walk around and solve puzzles. I will try to upload a web version every sunday, if there has been any progress.