how can i make drag and release (like pinball games) to shoot the ball with charge power in 3d mobile game
Hello, I'm new to use unity 5, and I'm now using c# to build a pinball type mobile game. how can i make drag and release (like pinball games) to shoot the ball with charge power in 3d mobile game?
Answer by ting703 · Mar 14, 2017 at 01:42 PM
I find this script and it works with my model, but the y axis is too sensitive. how can i set a max length of the movement? if (Input.touchCount > 0) { for (int i = 0; i < Input.touchCount; i++) { currentTouch = Input.GetTouch (i); if (Input.GetTouch (i).phase == TouchPhase.Moved) { ray = Camera.main.ScreenPointToRay (Input.GetTouch (i).position); if (Physics.Raycast (ray, out rayHitInfo)) { Vector2 v2 = currentTouch.deltaPosition; Vector3 v3 = new Vector3 (transform.position.x, v2.y*Time.deltaTime/50 , transform.position.z); cube.transform.position = v3; } } } }
Your answer
![](https://koobas.hobune.stream/wayback/20220612113141im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Ball going through and sticking to flippers in a pinball game 1 Answer
Pinball flippers, phantom flippers help! 0 Answers
pinball flipper bug 1 Answer
how to go about scripting object movement with hingejoint2d 0 Answers
Hinge joint won't work 1 Answer