Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void FixedUpdate()
- {
- foreach (Touch touch in Input.touches)
- {
- if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved)
- {
- Vector2 touchDeltaPosition = Input.GetTouch(0).deltaPosition;
- Vector2 pos = touchDeltaPosition;
- pos.x = touchDeltaPosition.x * speed;
- pos.y = touchDeltaPosition.y * speed;
- transform.Translate(pos.x,pos.y,0);
- Ray ray = Camera.main.ScreenPointToRay(touch.position);
- RaycastHit hit;
- if (Physics.Raycast(ray, out hit, 1000))
- {
- if (hit.collider.tag=="Environment")
- {
- Cubecall();
- }
- }
- }
- }
- }
- void Cubecall()
- {
- anim.enabled = true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement