Brand new to unity
Basicly im brand new,im wondering what the good resources are and what tutorials i should be following. I tried following the roll a ball tutorial, but couldn't manage to get the ball rolling (code below)
sing UnityEngine; using System.Collections;
public class PlayerController : MonoBehaviour { public float speed;
private Rigidbody rb;
void Start()
{
rb = GetComponent <Rigidbody>();
}
void FixUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movment = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rb.AddForce (movment * speed);
}
}
anyways many thanks in advance and you any help you have would be great
Answer by UnityCoach · Mar 23, 2017 at 02:01 PM
Hi,
Game loop and events MonoBehaviour methods like Awake, Start, Update, FixedUpdate are messages and not base class methods you override. In other words, the MonoBehaviour receives messages throughout its lifecycle, that you catch by implementing a method you name after the message. There's no autocomplete, and no error when you misspell a message. You need to name the method FixedUpdate so that it catches the message. If you name it fixedUpdate, or FixUpdate, or anything else, it's a valid method, but it doesn't catch any message.
You always want to keep an eye on the name you give your methods, as they can also catch an unwanted message. All the messages a MonoBehaviour receives are documented here.
Regarding your question on learning Unity, please have a look at this training course. It covers everything you need to become a kickass developer with Unity and C#.
Your answer
Follow this Question
Related Questions
Negative Score 2 Answers
FindWithTag object is referenced as "Preview Scene" 5 Answers
Character Controller moving at different Framrates? [Unsolved] 0 Answers
Assign all GameObjects with tag "x" to a different Layer? 1 Answer
How can I make something happen when my character i sin a certain range of something. 1 Answer