From b62c7ec98596874348899a64fa580620ae8deec6 Mon Sep 17 00:00:00 2001 From: jk Date: Wed, 3 Dec 2014 14:31:15 +0900 Subject: [PATCH 1/3] Added touch controls --- .../Done/Done_Scripts/Done_GameController.cs | 2 +- .../Done_Scripts/Done_PlayerController.cs | 33 ++++++++++++++++++ ProjectSettings/EditorBuildSettings.asset | Bin 4140 -> 4140 bytes ProjectSettings/Physics2DSettings.asset | Bin 4260 -> 4260 bytes ProjectSettings/ProjectSettings.asset | Bin 19832 -> 20224 bytes 5 files changed, 34 insertions(+), 1 deletion(-) diff --git a/Assets/Done/Done_Scripts/Done_GameController.cs b/Assets/Done/Done_Scripts/Done_GameController.cs index 4b65419..5956979 100644 --- a/Assets/Done/Done_Scripts/Done_GameController.cs +++ b/Assets/Done/Done_Scripts/Done_GameController.cs @@ -33,7 +33,7 @@ void Update () { if (restart) { - if (Input.GetKeyDown (KeyCode.R)) + if ( (Input.GetKeyDown (KeyCode.R)) || (Input.touchCount > 0) ) { Application.LoadLevel (Application.loadedLevel); } diff --git a/Assets/Done/Done_Scripts/Done_PlayerController.cs b/Assets/Done/Done_Scripts/Done_PlayerController.cs index 9892460..d2b5e77 100644 --- a/Assets/Done/Done_Scripts/Done_PlayerController.cs +++ b/Assets/Done/Done_Scripts/Done_PlayerController.cs @@ -34,6 +34,39 @@ void FixedUpdate () float moveHorizontal = Input.GetAxis ("Horizontal"); float moveVertical = Input.GetAxis ("Vertical"); + + //check for touches.. move ship towards first touch if present + if(Input.touchCount > 0) + { + Touch touch = Input.GetTouch(0); + + if (touch.phase == TouchPhase.Stationary || touch.phase == TouchPhase.Moved) + { + Vector3 touchPosition = Camera.main.ScreenToWorldPoint(new Vector3(touch.position.x, touch.position.y, 0 )); + + if( touchPosition.x > transform.position.x ) + { + moveHorizontal = 1f; + } + else + { + moveHorizontal = -1f; + } + + if( touchPosition.z > transform.position.z ) + { + moveVertical = 1f; + } + else + { + moveVertical = -1f; + } + + } + //return; + } + + Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical); rigidbody.velocity = movement * speed; diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset index 3bf9e6684dd7c8caff94244e8e29f1fb717155f5..f95b739029fdd30d33a0fab8453433b0b596b559 100644 GIT binary patch delta 20 bcmZ3Zuts5m1hYw+;YR7V{EQ5fIR%sfM3V)l delta 20 bcmZ3Zuts5m1hYY!$wuk7{EUo~IR%sfM1=*X diff --git a/ProjectSettings/Physics2DSettings.asset b/ProjectSettings/Physics2DSettings.asset index b9740ec9ee8f080563619fc0b3b1df59eb9616d6..ab4e04d8b7f49a6f62560b2186f37f739e87cfb7 100644 GIT binary patch delta 14 VcmZ3YxI}S+1hYw+;YR6B0RSUf1ZDsL delta 14 VcmZ3YxI}S+1hYY!$wui;0RSUS1Z4mK diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 84b2e92e5e05c84fbd7a136c990722d83794e314..1506ee52e751cff8b3bcbfc76458b0845d602526 100644 GIT binary patch delta 3267 zcmYM0eSDME6~}X+P}|Zp?`fVUP1>Zi&^ENTh1M3<7YYQb6bhA1*c#Hs6O zt4t~QLOqJSiw>sql@67OC{%f!I(6f-4G~w|=Ef!)=r*03y7T}Dx#!;J zKKD7FZ>Rpg($6jW&gQBY~iX#PgFhMy zchxldpkAp?CqLCwQ>``{&HUxQxti`sxV1MBMPDbzRa~tr;1jy3RLqxj3is;_d_ zE!?TgNh(>TNf41=!$%8ktktK}YTlpbrT||c7qxPhD~p1xpJ?TMdI#MoDH_=|C4t}5 z+o&x*N-=n-9iz+ML|$k}qY$FpgeW&7N(YY^im5a1lWer{kkN!_mBuVSCgWbCov+CM zlSYMZ5oJ1`H<~DdUb4x;>rE!Eo;-;wOqmpASBjOxCNuTMW9~F5)Ccw3CJU`W?<7T5@f}Jsrzl!t?D~V)^@p(QTX;aZnjVIIE9~1~-!3z` zc}_+K?Z8YsG1D$-jeOaj#78sCv>RTJ@D~{_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pa8&2eW;zTasME)+v z<>QMbHu?wPKNIj%z>5Ma>0bb!CBVM{{sWg@s?dJ{|CfN506zyjR+>v+7?4bC4F`yL zZB39y@R>;(ca^Dh8Ar=PG!iTgEFJ9qvLKnkMuBC3WhQ+Yys_LuS>V~=IpDc6D(tQ( zq|tn#MPcL5cUM_X#`NAEybB8)Ryb^MC~%ysaFZ$y7kewMWapg`Cr2t>>)& z@IvsSVcg7@sxznLCe3G9HqKuOxPA1fBpq5qOe}3U98{sVQ|# zr|SYV8OqC{Y=*KW5vVRL_p08-v95Se9Q8#YY=y85!YjTMa^^TIwS#wncY=4N`0jBw zngZSp{!Q?yDc(?TqiNt*f=>s(D#7c0Gy`lV*wtXOWK_5(tkE?nrzf1lyTb}yi`8r4 zBAU$?!gDwj9xoeTCk=-29YhiF21J~Xh{1+RX)p|D49%i87eJ9D%N3}12{VquEhUB}3ggx+j zky_~j_O|M@3vu6RwbE|PVlE4xk4R_I>ZV7b*ppH`_BDmC%_*IM5##Zc;t8ohIIENKXg z(|Zy8F!)R0<_GaWYnT;iB3OW^D)oGzw zJk%N3I%O2^>wLrGls0I7ysx4;-nTTm Date: Wed, 3 Dec 2014 14:41:04 +0900 Subject: [PATCH 2/3] Revert "Added touch controls" This reverts commit b62c7ec98596874348899a64fa580620ae8deec6. --- .../Done/Done_Scripts/Done_GameController.cs | 2 +- .../Done_Scripts/Done_PlayerController.cs | 33 ------------------ ProjectSettings/EditorBuildSettings.asset | Bin 4140 -> 4140 bytes ProjectSettings/Physics2DSettings.asset | Bin 4260 -> 4260 bytes ProjectSettings/ProjectSettings.asset | Bin 20224 -> 19832 bytes 5 files changed, 1 insertion(+), 34 deletions(-) diff --git a/Assets/Done/Done_Scripts/Done_GameController.cs b/Assets/Done/Done_Scripts/Done_GameController.cs index 5956979..4b65419 100644 --- a/Assets/Done/Done_Scripts/Done_GameController.cs +++ b/Assets/Done/Done_Scripts/Done_GameController.cs @@ -33,7 +33,7 @@ void Update () { if (restart) { - if ( (Input.GetKeyDown (KeyCode.R)) || (Input.touchCount > 0) ) + if (Input.GetKeyDown (KeyCode.R)) { Application.LoadLevel (Application.loadedLevel); } diff --git a/Assets/Done/Done_Scripts/Done_PlayerController.cs b/Assets/Done/Done_Scripts/Done_PlayerController.cs index d2b5e77..9892460 100644 --- a/Assets/Done/Done_Scripts/Done_PlayerController.cs +++ b/Assets/Done/Done_Scripts/Done_PlayerController.cs @@ -34,39 +34,6 @@ void FixedUpdate () float moveHorizontal = Input.GetAxis ("Horizontal"); float moveVertical = Input.GetAxis ("Vertical"); - - //check for touches.. move ship towards first touch if present - if(Input.touchCount > 0) - { - Touch touch = Input.GetTouch(0); - - if (touch.phase == TouchPhase.Stationary || touch.phase == TouchPhase.Moved) - { - Vector3 touchPosition = Camera.main.ScreenToWorldPoint(new Vector3(touch.position.x, touch.position.y, 0 )); - - if( touchPosition.x > transform.position.x ) - { - moveHorizontal = 1f; - } - else - { - moveHorizontal = -1f; - } - - if( touchPosition.z > transform.position.z ) - { - moveVertical = 1f; - } - else - { - moveVertical = -1f; - } - - } - //return; - } - - Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical); rigidbody.velocity = movement * speed; diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset index f95b739029fdd30d33a0fab8453433b0b596b559..3bf9e6684dd7c8caff94244e8e29f1fb717155f5 100644 GIT binary patch delta 20 bcmZ3Zuts5m1hYY!$wuk7{EUo~IR%sfM1=*X delta 20 bcmZ3Zuts5m1hYw+;YR7V{EQ5fIR%sfM3V)l diff --git a/ProjectSettings/Physics2DSettings.asset b/ProjectSettings/Physics2DSettings.asset index ab4e04d8b7f49a6f62560b2186f37f739e87cfb7..b9740ec9ee8f080563619fc0b3b1df59eb9616d6 100644 GIT binary patch delta 14 VcmZ3YxI}S+1hYY!$wui;0RSUS1Z4mK delta 14 VcmZ3YxI}S+1hYw+;YR6B0RSUf1ZDsL diff --git a/ProjectSettings/ProjectSettings.asset b/Pro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5^9QIYvDQWF|+^0wtG3s+CwM^7# z2Bdl)VEw{$E?9WRnJ%M1xYK)mXl)=I>GsO!IS_1W4~L_{h@b-*i!Ko-TpRsAdoEAU From 71cbf74300d4f9c9d16548331cb137d790a1bfea Mon Sep 17 00:00:00 2001 From: jk Date: Wed, 3 Dec 2014 14:49:08 +0900 Subject: [PATCH 3/3] Added touch controls --- .../Done/Done_Scripts/Done_GameController.cs | 2 +- .../Done_Scripts/Done_PlayerController.cs | 51 +++++++++++++++---- 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/Assets/Done/Done_Scripts/Done_GameController.cs b/Assets/Done/Done_Scripts/Done_GameController.cs index 4b65419..5956979 100644 --- a/Assets/Done/Done_Scripts/Done_GameController.cs +++ b/Assets/Done/Done_Scripts/Done_GameController.cs @@ -33,7 +33,7 @@ void Update () { if (restart) { - if (Input.GetKeyDown (KeyCode.R)) + if ( (Input.GetKeyDown (KeyCode.R)) || (Input.touchCount > 0) ) { Application.LoadLevel (Application.loadedLevel); } diff --git a/Assets/Done/Done_Scripts/Done_PlayerController.cs b/Assets/Done/Done_Scripts/Done_PlayerController.cs index 9892460..fc8b070 100644 --- a/Assets/Done/Done_Scripts/Done_PlayerController.cs +++ b/Assets/Done/Done_Scripts/Done_PlayerController.cs @@ -12,11 +12,11 @@ public class Done_PlayerController : MonoBehaviour public float speed; public float tilt; public Done_Boundary boundary; - + public GameObject shot; public Transform shotSpawn; public float fireRate; - + private float nextFire; void Update () @@ -28,21 +28,54 @@ void Update () audio.Play (); } } - + void FixedUpdate () { float moveHorizontal = Input.GetAxis ("Horizontal"); float moveVertical = Input.GetAxis ("Vertical"); - + + + //check for touches.. move ship towards first touch if present + if(Input.touchCount > 0) + { + Touch touch = Input.GetTouch(0); + + if (touch.phase == TouchPhase.Stationary || touch.phase == TouchPhase.Moved) + { + Vector3 touchPosition = Camera.main.ScreenToWorldPoint(new Vector3(touch.position.x, touch.position.y, 0 )); + + if( touchPosition.x > transform.position.x ) + { + moveHorizontal = 1f; + } + else + { + moveHorizontal = -1f; + } + + if( touchPosition.z > transform.position.z ) + { + moveVertical = 1f; + } + else + { + moveVertical = -1f; + } + + } + //return; + } + + Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical); rigidbody.velocity = movement * speed; rigidbody.position = new Vector3 - ( - Mathf.Clamp (rigidbody.position.x, boundary.xMin, boundary.xMax), - 0.0f, - Mathf.Clamp (rigidbody.position.z, boundary.zMin, boundary.zMax) - ); + ( + Mathf.Clamp (rigidbody.position.x, boundary.xMin, boundary.xMax), + 0.0f, + Mathf.Clamp (rigidbody.position.z, boundary.zMin, boundary.zMax) + ); rigidbody.rotation = Quaternion.Euler (0.0f, 0.0f, rigidbody.velocity.x * -tilt); }