I know absolutely nothing about Unity. I want to move a sphere with arrow keys. How would I do this? I have tagged it as player.
try this,I am not sure where it came from.
code/
using UnityEngine;
using System.Collections;
public class FPSMove : MonoBehaviour
{
// Use this for initialization
void Start()
{
}
// Update is called once per frame
public float speed;
void Update()
{
speed = 0.1f;
if (Input.GetKey(KeyCode.W))
{
transform.position += transform.forward * speed;
}
if (Input.GetKey(KeyCode.S))
{
transform.position -= transform.forward * speed;
}
if (Input.GetKey(KeyCode.A))
{
transform.position -= transform.right * speed;
}
if (Input.GetKey(KeyCode.D))
{
transform.position += transform.right * speed;
}
}
}
/code
The very first tutorial teaches exactly this (moving a sphere).
Tags have no functionality on their own. You must make use of scripting to actually use them. I recommend simply starting with the tutorials in the Unity Learn section of this site. The Roll-a-Ball project has the closest to what you’re looking for.
Hi There,
It really depends what you want to do in the end, and you might want to use built-in assets in some cases. If your goal is to be able to move a character around the virtual world, Unity already provides some very good built-in assets called Character Controllers. They can be imported as assets (Assets > Import Package > Character) and make it possible to navigate the scene through a First- or Third-Person using your keyboard and mouse. In other words, don’t reinvent the wheel and use the assets provided by Unity, in many cases, these will get you started really quickly.
If this something that you are trying to create (Character Controllers), I have created a step-by-step tutorial on this here. Give it a try and if you are still stuck, just give me a shout!
All the best.