Skip to content

Commit

Permalink
added new ship controls
Browse files Browse the repository at this point in the history
  • Loading branch information
maxilevi committed Nov 10, 2017
1 parent 3f9aabf commit 40c488d
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 73 deletions.
34 changes: 0 additions & 34 deletions Assets/Controls.cs

This file was deleted.

18 changes: 18 additions & 0 deletions Assets/FollowShip.cs
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) );
}
}
4 changes: 2 additions & 2 deletions Assets/Controls.cs.meta → Assets/FollowShip.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

120 changes: 85 additions & 35 deletions Assets/Game.unity
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &161534276
MeshRenderer:
Expand Down Expand Up @@ -213,6 +213,7 @@ GameObject:
- component: {fileID: 729518489}
- component: {fileID: 729518487}
- component: {fileID: 729518486}
- component: {fileID: 729518488}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
Expand Down Expand Up @@ -276,11 +277,11 @@ Transform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 729518478}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 2.09, z: -18.5}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalPosition: {x: 0, y: 2.09, z: -5.4243426}
m_LocalScale: {x: 1, y: 1, z: 0.2932077}
m_Children: []
m_Father: {fileID: 2004386719}
m_RootOrder: 0
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &729518483
MonoBehaviour:
Expand Down Expand Up @@ -395,6 +396,19 @@ MonoBehaviour:
separableBlurShader: {fileID: 4800000, guid: e97c14fbb5ea04c3a902cc533d7fc5d1, type: 3}
chromAberrationShader: {fileID: 4800000, guid: 2b4f29398d9484ccfa9fd220449f5eee,
type: 3}
--- !u!114 &729518488
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 729518478}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 71c008b860fb0d84493a7d181f51c970, type: 3}
m_Name:
m_EditorClassIdentifier:
TargetShip: {fileID: 1582243898}
Offset: {x: 0, y: 1, z: 10}
--- !u!114 &729518489
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -479,47 +493,47 @@ Prefab:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 2004386719}
m_TransformParent: {fileID: 1410985307}
m_Modifications:
- target: {fileID: 400000, guid: eab6d2f90fc33a248a5e1eee31c76846, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 400000, guid: eab6d2f90fc33a248a5e1eee31c76846, type: 3}
propertyPath: m_LocalPosition.y
value: -2.18
value: 0
objectReference: {fileID: 0}
- target: {fileID: 400000, guid: eab6d2f90fc33a248a5e1eee31c76846, type: 3}
propertyPath: m_LocalPosition.z
value: 14.21
value: 0
objectReference: {fileID: 0}
- target: {fileID: 400000, guid: eab6d2f90fc33a248a5e1eee31c76846, type: 3}
propertyPath: m_LocalRotation.x
value: -0.7071068
value: 0
objectReference: {fileID: 0}
- target: {fileID: 400000, guid: eab6d2f90fc33a248a5e1eee31c76846, type: 3}
propertyPath: m_LocalRotation.y
value: -0
value: 0
objectReference: {fileID: 0}
- target: {fileID: 400000, guid: eab6d2f90fc33a248a5e1eee31c76846, type: 3}
propertyPath: m_LocalRotation.z
value: -0
value: 0
objectReference: {fileID: 0}
- target: {fileID: 400000, guid: eab6d2f90fc33a248a5e1eee31c76846, type: 3}
propertyPath: m_LocalRotation.w
value: 0.7071068
value: 1
objectReference: {fileID: 0}
- target: {fileID: 400000, guid: eab6d2f90fc33a248a5e1eee31c76846, type: 3}
propertyPath: m_RootOrder
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 400000, guid: eab6d2f90fc33a248a5e1eee31c76846, type: 3}
propertyPath: m_LocalScale.y
value: 3.4105535
value: 1
objectReference: {fileID: 0}
- target: {fileID: 400000, guid: eab6d2f90fc33a248a5e1eee31c76846, type: 3}
propertyPath: m_LocalScale.z
value: 0.29320782
value: 0.2932082
objectReference: {fileID: 0}
- target: {fileID: 2300000, guid: eab6d2f90fc33a248a5e1eee31c76846, type: 3}
propertyPath: m_Materials.Array.data[0]
Expand All @@ -533,10 +547,60 @@ Prefab:
propertyPath: m_ReceiveShadows
value: 0
objectReference: {fileID: 0}
- target: {fileID: 100000, guid: eab6d2f90fc33a248a5e1eee31c76846, type: 3}
propertyPath: m_Name
value: Model
objectReference: {fileID: 0}
- target: {fileID: 400000, guid: eab6d2f90fc33a248a5e1eee31c76846, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
m_RemovedComponents:
- {fileID: 9500000, guid: eab6d2f90fc33a248a5e1eee31c76846, type: 3}
m_ParentPrefab: {fileID: 100100000, guid: eab6d2f90fc33a248a5e1eee31c76846, type: 3}
m_IsPrefabParent: 0
--- !u!1 &1410985306
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1410985307}
- component: {fileID: 1410985308}
m_Layer: 0
m_Name: Ship
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1410985307
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1410985306}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1582243899}
m_Father: {fileID: 2004386719}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1410985308
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1410985306}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9b67576e7da945d4abe2e66b1d91a4a9, type: 3}
m_Name:
m_EditorClassIdentifier:
Speed: 0
--- !u!1 &1582243898 stripped
GameObject:
m_PrefabParentObject: {fileID: 100000, guid: eab6d2f90fc33a248a5e1eee31c76846, type: 3}
Expand Down Expand Up @@ -603,7 +667,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1880731490
MonoBehaviour:
Expand Down Expand Up @@ -634,7 +698,6 @@ GameObject:
serializedVersion: 5
m_Component:
- component: {fileID: 2004386719}
- component: {fileID: 2004386720}
- component: {fileID: 2004386721}
m_Layer: 0
m_Name: Player
Expand All @@ -649,27 +712,14 @@ Transform:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2004386718}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalRotation: {x: -0.7071068, y: 0, z: 0, w: 0.7071068}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 0.2932077}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 729518482}
- {fileID: 1582243899}
- {fileID: 1410985307}
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2004386720
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2004386718}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: aebc15e318f4c7748bb9d3b03976707f, type: 3}
m_Name:
m_EditorClassIdentifier:
Speed: 32
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0}
--- !u!54 &2004386721
Rigidbody:
m_ObjectHideFlags: 0
Expand Down
39 changes: 39 additions & 0 deletions Assets/Movement.cs
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 );

}
}
}
13 changes: 13 additions & 0 deletions Assets/Movement.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions project-skylines.userprefs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" PreferredExecutionTarget="Unity.Instance.Unity Editor" />
<MonoDevelop.Ide.Workbench ActiveDocument="Assets\Controls.cs">
<Files>
<File FileName="Assets\Controls.cs" Line="8" Column="25" />
<File FileName="Assets\Generation\ChunkLoader.cs" Line="112" Column="49" />
<File FileName="Assets\Controls.cs" Line="26" Column="29" />
<File FileName="Assets\Generation\ChunkLoader.cs" Line="99" Column="32" />
<File FileName="Assets\Generation\GenerationQueue.cs" Line="36" Column="1" />
<File FileName="Assets\World.cs" Line="20" Column="1" />
<File FileName="Assets\Generation\GenerationThread.cs" Line="44" Column="6" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
Expand Down

0 comments on commit 40c488d

Please sign in to comment.