- Home /
Android Moving with finger without breaking physics
I am making a game that involves a torrent of sphere objects coming towards that player, and you have to bounce them back by moving the player with your finger. I am using transform.position to achieve this, but due to .positions nature of breaking physics, the enemies are going through the players collider some times especially when it hits the corner or side and gets stuck inside the player. could someone suggest a fix that would stop objects from going through or getting stuck in the player collider? Either an alternate physics safe way to move the player with your finger, or some other way to stop the enemies from going through, thanks! here is what i am currently using if it helps any
function OnMouseDrag()
{
point = Camera.main.ScreenToWorldPoint(
Vector3(
Input.mousePosition.x,
(transform.position.y-Camera.main.transform.position.y),
(transform.position.z-Camera.main.transform.position.z)));
point.y = transform.position.y;
point.z = transform.position.z;
farmer.transform.position = point;
}
I assume your player has a Rigidbody? If so, look at using Rigidbody.$$anonymous$$ovePosition() rather than directly moving through the transform. You might also look at using a joint to connect the finger position to the object like is done in the DragRigidbody.js script.
already tried using that, and for some reason didnt really make a difference, things were still going through the collider, bother the enemies are using a rigid body, but the player is kinematic, as for the joint thing, could you explain a little bit further please? I should also add that i locked the y and z position of the player
Your answer
Follow this Question
Related Questions
Finger gesture works/fails on different devices? 0 Answers
Ragdoll 2D character controller help 0 Answers
Adding a position offset to a force towards an object 1 Answer
How to make a sprite/gameobject follow your finger on Android? 2 Answers
Unity canvas keeps changing dimension and position 0 Answers