- Home /
Question by
dogukanerdem000 · May 30 at 02:54 PM ·
touchtouch controlstouchscreenbonesinverse kinematic
How to Move IK to the Touch Position
Hi, I have a 3d character in a 3d environment and I am trying to move the Two Bone IK Constraints > Target object to the "Touch Position" of the player so I can move and rotate them to avoid hitting some obstacles. The code I have so far is down below, but it is not working. Whenever I touch the screen, the target object snaps to the character and not moving anymore at all.
if (Touchscreen.current.primaryTouch.press.isPressed)
{
Vector3 touchPosition = Touchscreen.current.primaryTouch.position.ReadValue();
Vector3 worldPosition = mainCamera.ScreenToWorldPoint(touchPosition);
movementDirection = worldPosition - leftArmIK.transform.position;
leftArmIK.transform.position = new Vector3(movementDirection.x, movementDirection.y, movementDirection.z);
movementDirection.Normalize();
}
I have been trying to solve this problem since yesterday, but couldn't find a solution on my own. So I'd be so greatful for any help or advice.
Comment
Your answer
Follow this Question
Related Questions
define touch area 2 Answers
Possible to get touch area data? 1 Answer
Working with screen's touch limit 0 Answers
Make object follow my finger (Touch)? 1 Answer
Shump Touch Control 1 Answer