// Use this for initialization void Start () { if (isLocalPlayer) { touch = GetComponent<TouchMovement> (); currentStick = (GameObject)Instantiate (joystick, new Vector3 (0, 0, 0), Quaternion.identity); myStick = currentStick.GetComponent<Joystick> (); currentStick.SetActive (false); } }
void Start () { touchMovement = GetComponent<TouchMovement> (); coinController = GetComponent<CoinController> (); stealth = GetComponent<StealthMode> (); playerEnabled = true; camFollow = GameObject.Find ("Player Camera").GetComponent<CameraFollow> (); }
void Awake() { enemyController = FindObjectOfType <EnemyController> (); bulletSpeed = 5f + enemyController.difficulty; pauseManager = FindObjectOfType <PauseManager> (); touchMovement = FindObjectOfType <TouchMovement> (); playerPosition = touchMovement.playerPosition; moveDir = (playerPosition - transform.position).normalized; }
public void SetTouchData(SwipeControls controls) { TouchMovement swipeData = new TouchMovement { StartPos = startPosition, swipeControls = controls }; tData?.Invoke(swipeData); }
// Use this for initialization, run in child class's Start method protected void Setup () { myCollider = GetComponent<Collider2D> (); player = GetComponent<PlayerController> (); visual = GetComponentInChildren<SpriteRenderer> (); touchMoveObject = GetComponent<TouchMoveObject> (); ring = visual.gameObject.transform.FindChild ("ring").GetComponent<SpriteRenderer>(); stealthMode = GetComponent<StealthMode> (); player.SetClass (className); touchMovement = GetComponent<TouchMovement> (); }
/// <summary> /// Gains access to external scripts. /// </summary> void Start () { player = this.gameObject; GameObject camObj = GameObject.Find ("Player Camera"); cam = camObj.GetComponent<Camera> (); //gain reference to scripts for assigning to. playerController = GetComponent<PlayerController> (); touchMovement = GetComponent<TouchMovement> (); stealthMode = GetComponent<StealthMode> (); }
void Start() { playerStamina = playerMaxStamina; // Assign our Player's rigidybody to 'rigidbody' playerRB = GetComponent <Rigidbody2D>(); PlayerCollider = GetComponent <Collider2D>(); touchMovement = FindObjectOfType <TouchMovement>(); GameObject staminaBarObject = GameObject.FindGameObjectWithTag("StaminaBar"); staminaBarImage = staminaBarObject.GetComponent <Image>(); }
void CreateCube(TouchMovement touchData) { var x = Camera.main.ScreenToWorldPoint(new Vector3(touchData.StartPos.x, touchData.StartPos.y, 10)); Ray ray = Camera.main.ScreenPointToRay(touchData.StartPos); GraphicRaycaster gr = canvas.GetComponent <GraphicRaycaster>(); PointerEventData ped = new PointerEventData(null); ped.position = touchData.StartPos; List <RaycastResult> results = new List <RaycastResult>(); gr.Raycast(ped, results); if (results.Count <= 0) { if (!Physics.Raycast(ray, out RaycastHit hit)) { k = Instantiate(cubePrefab, x, Quaternion.identity); k.transform.SetParent(this.transform); } else { if (k != null && !hit.collider.CompareTag("Ground")) { bullets[currentBullet].transform.position = hit.collider.transform.position; bullets[currentBullet].transform.rotation = Quaternion.identity; bullets[currentBullet].SetActive(true); //Instantiate(bullets[currentBullet], hit.collider.transform.position, Quaternion.identity).transform.SetParent(hit.transform); currentBullet++; if (currentBullet >= bulletPoolSize) { currentBullet = 0; } } } } }
void SwipeData(TouchMovement movement) { Debug.Log("Position is " + movement.swipeControls); }
//bool isThrowing; void Start(){ player = this.gameObject; touchMovement = GetComponent<TouchMovement> (); }
void Start(){ touchMovement = GetComponent<TouchMovement> (); touchThrow = GetComponent<TouchThrow> (); }
TouchMovement GetTouchMovement() { TouchMovement m = new TouchMovement (); if (Input.touchCount > 0) { var touch0 = Input.GetTouch (0); Vector2 touch0Delta = touch0.phase == TouchPhase.Moved ? touch0.deltaPosition : Vector2.zero; if (Input.touchCount > 1) { var touch1 = Input.GetTouch (1); Vector2 touch1Delta = touch1.phase == TouchPhase.Moved ? touch1.deltaPosition : Vector2.zero; float old0Y = touch0.position.y - touch0Delta.y; float old1Y = touch1.position.y - touch1Delta.y; float old0X = touch0.position.x - touch0Delta.x; float old1X = touch1.position.x - touch1Delta.x; float currAngle = (float)Math.Atan2((touch1.position.y - touch0.position.y), (touch1.position.x - touch0.position.x)); float oldAngle = (float)Math.Atan2(((old1Y) - (old0Y)), ((old1X) - (old0X))); m.Tilt = currAngle - oldAngle; if (Math.Abs(m.Tilt) > 1) m.Tilt = 0; } else if (touch0.phase == TouchPhase.Moved) { // Get movement of the finger since last frame m.Drag = touch0.deltaPosition; } } return m; }