Question by
DarthDalek · Jun 02, 2016 at 10:00 PM ·
roll a ball
roll a ball not rolling, code seems correct...
i followed along with the guy and when he had me test the ball, i couldnt get it to roll for the life of me, so i decided to copy and paste his code... ... ... IT STILL DOESNT WORK! one notable difference i can see is that for him in "Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);" the "0.0f" is a different color and for me it is the same color as all the text
using UnityEngine;
using System.Collections;
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
Answer by Static-Dynamo · Jun 02, 2016 at 11:15 PM
Here are a few things to check-
Does your console show any errors or messages?
Does your ball have a rigidbody attached to it?
Does your ball have the script attached to it?
Did you put in a value for the speed?