Question by
shayaans · Sep 20, 2015 at 06:56 PM ·
movementcamera-movement
Roll A Ball Tutorial Player Not Moving
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);
Debug.Log("Horizontal Speed: " + moveHorizontal.ToString());
Debug.Log("Vertical Speed: " + moveVertical.ToString());
}
}
When I press an arrow key, I see values appearing in my console but the ball DOESN'T MOVE
I removed rigidBody from my player then re-added it and it doesn't move.
I Moved the camera as the child of the Player (because I wanted to tie them together)
Comment