teaching machines

HNRS 304.503 Lecture 16 – A boat, fixed coin spin-up, water, and a message box

Agenda

  • Your models
  • Character Controller
  • Fixing animation from last time
    • Span animation window across all actions
    • Parent a model with an empty, position the empty
  • Modeling a boat in 5 minutes
  • Adding water
  • Using GUI.Box for messages
  • Themes

Modeling a boat

  1. Make a long, thin rectangular prism.
  2. Select the top and bottom faces.
  3. Subdivide with some odd number of cuts.
  4. Select all prow faces.
  5. Turn on proportional editing, sharp mode.
  6. Scale inward to 0 (sx0, if on the x-axis), mouse-wheeling to change the sphere of influence.
  7. Remove doubles.
  8. Select all stern faces.
  9. Scale inward, but not to 0.
  10. Loop cut and slide all three sides to make a foundation for the walls.
  11. Extrude up.
  12. Scale out.
  13. Select the two vertices on the bottom of the prow.
  14. Merge.
  15. Raise the bottom of the prow up.
  16. Add two seats.
  17. Scale front and back faces independently.

Water

  1. Create terrain.
  2. Import Water package.
  3. Drag water into project.
  4. Scale.

Meet Boat

  1. Place boat.
  2. Add an empty on the shore near the boat.
  3. Give it a sphere collider.
  4. Make collider a trigger.
  5. Add a script:
    private bool isNearBoat;
    private GameObject player;
    public GUISkin skin;
    
    void Start() {
      player = GameObject.Find("Player");
    }
    
    void OnGUI() {
      if (isNearBoat && !player.GetComponent<CharacterMotor>().jumping.enabled) {
        GUI.Box(new Rect(10, Screen.height - 70, Screen.width - 20, 60), "You're too heavy laden to board the boat.", skin.box));
      }
    }
    
    void OnTriggerEnter(Collider collider) {
      isNearBoat = true;
    }
    
    void OnTriggerExit(Collider collider) {
      isNearBoat = false;
    }
  6. Add GUI Skin in project panel.
  7. Increase box font size.
  8. Add script to empty.

Flip-up coins

  1. Add an empty where you want a coin to appear.
  2. Add a coin as a child object.
  3. Add a collider to the empty.
  4. Make the collider a trigger.
  5. Add a script to the empty, which will need to access it’s child object:
    private Transform coin;
    private bool isHit;
    private GameObject player;
    
    void Start() {
      coin = transform.Find("greedee_coin");
      isHit = false;
      player = GameObject.Find("Player");
    }
    
    void Update() {
      if (isHit) {
        // keep the coin in view
        transform.position = player.transform.position + 2.0f * player.transform.forward;
      }
    }
    
    void OnTriggerEnter(Collider collider) {
      if (!coin.animation.IsPlaying("dissipate")) {
        isHit = true;
        coin.animation.Play("dissipate");
        Destroy(gameObject, 2.0f);
        player.GetComponent<CharacterMotor>().jumping.enabled = false;
      }
    }

Haiku

“Three wishes I’ll grant”
The third is three more wishes
Or 3-d printer

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *