You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
	
	
		
			
				
					
						
							|  |  |  |  | using UnityEngine; | 
					
						
							|  |  |  |  | using System.Collections; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | public class ShipPlayerController : MonoBehaviour | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	public float m_speed = 1f; | 
					
						
							|  |  |  |  | 	public float m_rotationSpeed = 1f; | 
					
						
							|  |  |  |  |     public Renderer m_moveArea; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	void Update() | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		if (Input.GetKey(KeyCode.LeftArrow)) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			transform.Rotate(new Vector3(0f, 0f, m_rotationSpeed * Time.deltaTime)); | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		if (Input.GetKey(KeyCode.RightArrow)) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			transform.Rotate(new Vector3(0f, 0f, -m_rotationSpeed * Time.deltaTime)); | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		Vector3 dir = transform.rotation * Vector3.right; | 
					
						
							|  |  |  |  | 		transform.position += dir * m_speed * Time.deltaTime; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         if (!m_moveArea.bounds.Contains(transform.position)) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Vector3 new_pos = transform.position; | 
					
						
							|  |  |  |  |             if (transform.position.x > m_moveArea.bounds.max.x) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 new_pos.x = m_moveArea.bounds.min.x; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else if (transform.position.x < m_moveArea.bounds.min.x) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 new_pos.x = m_moveArea.bounds.max.x; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             if (transform.position.y > m_moveArea.bounds.max.y) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 new_pos.y = m_moveArea.bounds.min.y; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else if (transform.position.y < m_moveArea.bounds.min.y) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 new_pos.y = m_moveArea.bounds.max.y; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             transform.position = new_pos; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | } |