I wrote the following script:
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKey("W"))
{
rigidbody.AddForce(new Vector3(0,100), ForceMode.Force);
}
if (Input.GetKey("A"))
{
rigidbody.AddForce(new Vector3(100,0), ForceMode.Force);
}
if (Input.GetKey("S"))
{
rigidbody.AddForce(new Vector3(0,-100), ForceMode.Force);
}
if (Input.GetKey("D"))
{
rigidbody.AddForce(new Vector3(-100,0), ForceMode.Force);
}
}
}
As you can see, a basic script which ought to move the object i dropped it on when i press the WASD keys. However, putting it on my object, it doesnt work. Am i doing anything obviously wrong or anything?
My object is a combo plane/BoxCollider with the plane rotated 90 degrees (to face my camera, the Z axis points down now), and it is constrained to 2 dimensions (X and Y).