Traveling Light on Switch and Doors!

Got the light on the line to work together with the switch:

box_traveling_light

I think it works better for the entire line to go off when the box is removed, instead of having the light slowly retreat, as that would look pretty weird just to have the light on but not the box there. Also feels more snappy that way.

Also worked on door animation: door-opening

I think I’d like to draw up some more designs of doors. I like the way this opens (feels very equal on all sides, which is necessary for the mechanic), but I wonder if the actual design can be improved.

Calling the door animation from script was a bit more tricky as Unity 5 has changed the API for animation, and it’s quite confusing coming from Unity 4.

Basically, it seems like one has to use animator now instead of animation component, and it’s animation states instead of animation clips.

Here’s how the script looked to get the call the animation from within a script:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
using UnityEngine;
using System.Collections;public class DoorController : MonoBehaviour {
void Start () {

}

// Update is called once per frame
void Update () {

if (Input.GetKeyDown(KeyCode.T)) {

GetComponent<Animator>().Play("DoorOpen");
}

if (Input.GetKeyDown(KeyCode.Y)) {

GetComponent<Animator>().Play("DoorClose");
}

}
}

Once that was done, it was just a matter of connecting the door to the switch: switch-door-light-almost

It feels quite satisfying, but I’m going to make it so that the door doesn’t open until the light travels across the path and hits it. Right now the door opens right when the box gets placed on the square, and I think it feels a little bit off.

  • Facebook
  • Twitter
  • Tumblr
  • LinkedIn
  • del.icio.us
  • Google Bookmarks
  • Reddit
  • StumbleUpon
  • RSS