- Home /
Question by
Mihaipunct · Jun 25, 2020 at 04:20 PM ·
rollcylinder
Roll a cylinder,Spin a cylinder
I am new to C# and unit. I watched the roll a ball tutorial and wanted to make a "roll" game but instead of a ball you roll a cylinder. I managed to make the cylinder move back and forth, but now i am stuck. I want to make the cylinder spin around Y axis so i can change the direction in which the player is going. He is my code so far: public class PlayerController : MonoBehaviour {
public float speed;
private Rigidbody rb;
void Start ()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rb.AddForce (movement * speed);
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613001738im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Cylinder object does not roll as intended 1 Answer
cylinder pulling mechanism 0 Answers
Programming Movement Momentum 0 Answers