Question by
ZeeshanQaswar · Jan 26, 2021 at 08:08 PM ·
physicsgame development
Walk player around Cylinder
Hi, I am working on a personal project. I want my player to walk on Cylinder. How can I implement it. I googled and find some solutions but was not able to implement them according to my requirement. This is what I did which does not work.
public void FixedTick(float delta, Rigidbody rb)
{
Vector3 gravityDir = Vector3.ProjectOnPlane((envProp.position - transform.position), envProp.up);
rb.AddForce( gravityDir * 9.8f,ForceMode.Acceleration);
Vector3 localX = Vector3.Cross(transform.forward, gravityDir);
//Vector3 localZ = Vector3.Cross(gravityDir, localX);
Quaternion currentRot = Quaternion.LookRotation(transform.up, gravityDir);
transform.localRotation = currentRot;
}
Comment
Your answer
Follow this Question
Related Questions
Player jumps randomly after a jump 0 Answers
How does hinge joint work? 0 Answers
Two Vectors Beetween Angle 0 Answers
Move rigidbody cube without it tumbling 2 Answers
Can I ignore part of a vector3 for physics reasons? 0 Answers