You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
657 B

  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class BoatController : BuoyantObject {
  6. public float trunSpeed = 0.5f;
  7. // Use this for initialization
  8. void Start () {
  9. }
  10. void Update() {
  11. lookAtDir(Vector3.ProjectOnPlane(rb.velocity, Vector3.up));
  12. }
  13. // Update is called once per frame
  14. void lookAtDir(Vector3 inputDir) {
  15. Quaternion targetRotation = Quaternion.LookRotation(inputDir,Vector3.up);
  16. float str = Mathf.Min(trunSpeed * Time.deltaTime, 1);
  17. transform.rotation = Quaternion.Lerp(transform.rotation, targetRotation, str);
  18. }
  19. }