- Home /
Ragdoll 2D character controller help
I need my character in my game to move in a strange way. I want my character to move and follow the mouse position so like its a drag a drop sort of movement but there should be some bit of drag so the character isnt fully under the mouse position. I already have a 2D rigidbody under the character so there is already physics.
void Update () {
if (inGame == true) {
if (Input.GetMouseButtonDown (0)) {
Vector2 playerPosition = Input.mousePosition;
playerPosition = Camera.main.ScreenToWorldPoint (playerPosition);
transform.position = playerPosition;
}
} else {
}
}
All my current code does change the characters position statically where the mouse is every time its clicked instead of it being dragged around with a bit of drag (physics) in it. How do i do write this?
Your answer
Follow this Question
Related Questions
Android Moving with finger without breaking physics 0 Answers
Finger gesture works/fails on different devices? 0 Answers
Drag and Swap two object using touch 0 Answers
Android touch and drag GUItexture problem 0 Answers
Right Mouse Click in Android 2 Answers