// Update is called once per frame void Update() { /* if (line.enabled == true) { * * line.SetPosition(0, transform.position); * line.SetPosition(1, anchor.transform.position); * }*/ //we don't want to have to call the SetCustomCursor every frame, so before wecheck the valwith the previous frame to see wif we need to call it bool previosFrameCanGrapple = cc.canGrapple; mousePosition = Cam.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0)); //get player position playerPosition = transform.position; mouseDir = mousePosition - playerPosition; //as the name would suggest this gets the angle that the player is aiming at var aimAngle = Mathf.Atan2(mouseDir.y, mouseDir.x); //make sure we have a positive angle if (aimAngle < 0f) { aimAngle = Mathf.PI * 2 + aimAngle; } var aimDirection = Quaternion.Euler(0, 0, aimAngle * Mathf.Rad2Deg) * Vector2.right; //send out a raycast every frame to see if we need to change the cursor canGrapple = Physics2D.Raycast(playerPosition, aimDirection, ropeMaxShootDistance, canColide); if (canGrapple.collider != null) { if (canGrapple.collider.gameObject.GetComponent <Rigidbody2D>() != null && !previosFrameCanGrapple) { cc.canGrapple = true; cc.SetCustomCursor(); } } else if (canGrapple.collider == null && previosFrameCanGrapple) { cc.canGrapple = false; cc.SetCustomCursor(); } inputHandler(aimDirection); updateRope(); }
// Update is called once per frame void Update() { GameObject cc = GameObject.Find("Main Camera"); CustomCursor other = (CustomCursor)cc.GetComponent(typeof(CustomCursor)); if (isPaused) { pauseMenuCanvas.SetActive(true); other.OnDisable(); Time.timeScale = 0f; } else { pauseMenuCanvas.SetActive(false); other.SetCustomCursor(); Time.timeScale = 1f; } if (Input.GetKeyDown(KeyCode.Escape)) { isPaused = !isPaused; } }