Mouse-Keyboard Not Working - New User
New Unity User...
Following the exact tutorial for the Roll-A-Ball game.
When I play the game the ball doesn't move.
I doubled check all ideas about the input not working across Google and this forum...
- - Change speed to 500
- - Delete reg key (which I didn't have an input value)
- - Change "fixupdate" to "FixedUpdate"
- - Double checked code (I copied and pasted the tutorial code)
- - Make sure the tick box is check next to the "PlayerController" script.
Thanks in advance
=================================
Okay... I found some totally different C# code that works fine. So, it's not Unity app. It's the Tutorial code... I used exactly like they have but it doesn't work. However, the new code doesn't use AddForce so I can get a smooth rolling ball. But, at least I know it's the tutorial code that is the problem.
Onward I go!
Here is the code from the tutorial
I suspect the problem is on one of these lines...
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
rb.AddForce(movement * speed);
using UnityEngine;
using System.Collections;
public class PlayerController : $$anonymous$$onoBehaviour
{
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);
}
}
After testing (printing on console) the value of X & Z are working....
So why isn't the object moving???
The problem has to be on this line...
rb.AddForce(movement * speed);
Answer by TechniPixel · Jun 30, 2016 at 06:17 PM
Finally figured it out.... Someone needs to change the tutorial code.
I needed to use "Velocity" not "movement"
rb.velocity = movement * speed;