- Home /
Buggy touch controls?
Please I have literally no idea how to prevent this from happening. The best thing that comes to my mind is that Unity just makes touch controls buggy but I don't know... Please take a look at the video then at the code: VIDEO TOUCH CONTROLS BUGGY
I don't know the other way to attach videos here so I packed into zip. The code is ok I think and worked perfectly but when I touch literally the edge on the other side of the ball the capsule (Red object) teleports instantly to that position I don't want it that way I want to block this "cheat" and force the user to move the capsule around the ball not to just touch the edge on the other side of the ball and voila capsule teleports to the bottom. Code:
Vector3 v = transform.position - origin.position;
v = Vector3.ClampMagnitude(v, origin.GetComponent<CircleCollider2D>().radius + 1.3f);
transform.position = origin.position + v;
The origin is the ball in the center, the round one. I copied it and made a capsule (not the red object) as you can see it covers the round ball in the center and the red capsule which we control is supposed to be INSTANTLY blocked when collision happens and user is forced to go around with the red capsule. I'm not good at Rigidbodies and that stuff. I guess I'm not good at explaining too but I hope you understood. A picture maybe you will better understand.
Your answer
Follow this Question
Related Questions
How to make certain rigidbody2d's not able to push other rigidbody2d's? 2 Answers
Sprites collision not working on high speeds 1 Answer
"Freeze Position" applied to an axis affects the bounciness of the object's collider on that axis. 0 Answers
Weird collision with objects passing through each other 1 Answer