How do I get a character to move (Without the default scripts, which don't seem to work)?
I'm basically making a test/joke game, so I don't care about the details too much, just want to make something actually happen. This is my first time trying to use Unity. The character is a rectangular prism with no animations. I have a rigidbody, a box collider, and the script "moving better hopefully", which I found online (I named it though)
using UnityEngine; using System.Collections;
public class movingBetterHopefully : 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);
}
}
(Sorry for the formatting...)
I can set the inputs when I build the game, but the character can't actually move. What do I need to do here? Thanks in advance, and sorry for being pretty ignorant about the whole process... I've been trying to get this working for probably a week now and getting pretty frustrated.
The first thing you should do is insert Debug.Log lines and/or put the movement variable into the main body of the script and make it public so it's values are seen in the inspector. That lets you check if there's actually any movement happening in theory. Same goes for the Axis... Check if their values actually change on input.
Answer by ZeraTFK · Nov 16, 2015 at 10:21 AM
What is your Speed value? If the value equal 0 then it wont move. if the value less then ~10.. 15.. and the Mass of your Rigidbody is 1 then it move very very very very slow until nothing.
Be sure the Speed is != 0 and Lower the Mass || increase the speed * 10 or 100
I add a example to download $$anonymous$$oveArrowRigidbodyForce
That was the issue, turns out my speed was only set to 1... :P Thanks for the help!