-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
162 additions
and
73 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
|
||
public class FollowShip : MonoBehaviour { | ||
|
||
public GameObject TargetShip; | ||
public Vector3 Offset; | ||
|
||
void Update () { | ||
this.transform.position = Lerp (this.transform.position, TargetShip.transform.position + TargetShip.transform.forward * Offset.z + TargetShip.transform.up * Offset.y, Time.deltaTime * 16f); | ||
this.transform.LookAt(TargetShip.transform.position + Vector3.up, Vector3.up); | ||
//this.transform.rotation = Quaternion.Slerp(this.transform.rotation, TargetShip.transform.rotation, Time.deltaTime * 32f); | ||
} | ||
|
||
public Vector3 Lerp(Vector3 A, Vector3 B, float C){ | ||
return new Vector3 (Mathf.Lerp(A.x, B.x, C), Mathf.Lerp(A.y, B.y, C), Mathf.Lerp(A.z, B.z, C) ); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
|
||
public class Movement : MonoBehaviour { | ||
|
||
public float Speed = 16; | ||
public float TurnSpeed = 3f; | ||
// Use this for initialization | ||
void Start () { | ||
|
||
} | ||
|
||
// Update is called once per frame | ||
void Update () { | ||
transform.parent.position += transform.forward * Time.deltaTime * 4 * Speed; | ||
transform.localRotation = Quaternion.Slerp(transform.localRotation, Quaternion.Euler(Vector3.zero), Time.deltaTime * 1.5f); | ||
Debug.Log(transform.rotation.eulerAngles + " | " + transform.localRotation.eulerAngles); | ||
if (Input.GetKey(KeyCode.W)) | ||
{ | ||
transform.localRotation = Quaternion.Euler(transform.localRotation.eulerAngles + Vector3.right * Time.deltaTime * 64f * TurnSpeed); | ||
} | ||
|
||
if (Input.GetKey(KeyCode.S)) | ||
{ | ||
transform.localRotation = Quaternion.Euler(transform.localRotation.eulerAngles - Vector3.right * Time.deltaTime * 64f * TurnSpeed); | ||
} | ||
|
||
if (Input.GetKey (KeyCode.A)) { | ||
transform.localRotation = Quaternion.Euler(transform.localRotation.eulerAngles + Vector3.forward * Time.deltaTime * 64f * TurnSpeed); | ||
transform.parent.Rotate(- Vector3.up * Time.deltaTime * 64f * TurnSpeed ); | ||
} | ||
|
||
if (Input.GetKey (KeyCode.D)) { | ||
transform.localRotation = Quaternion.Euler(transform.localRotation.eulerAngles - Vector3.forward * Time.deltaTime * 64f * TurnSpeed); | ||
transform.parent.Rotate( Vector3.up * Time.deltaTime * 64f * TurnSpeed ); | ||
|
||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters