- Home /
Moving a wheel character
i have a character with two wheels as its legs,i want the wheels to rotate as they move and also to look left and right based on hit points.
i have applied velocity to move the wheel which rotates the wheel as they have capsule collider:
lookvector = (hitpoint - transform.position).normalized;
lookvector.y = 0;
Body.velocity = Vector3.zero;
Body.velocity = lookvector * moving_speed * Time.deltaTime;
Body is the rigidbody of the wheel.
Now for the left and right look:
lookrot = Quaternion.LookRotation(lookvector);
transform.rotation = Quaternion.Lerp(transform.rotation, lookrot, look_speed * Time.deltaTime);
but now the rotation caused by the velocity of rigidbody and the left right look rotation interfers with each other as a result it moves as if the wheel is just being dragged. How can i seperate the two rotations from each other. i want the left right look rotation only along the y axis and rigidbody rotation along the x axis,how can i achieve this?
Comment