This question was
closed Dec 16, 2015 at 07:51 AM by
John_Freeman for the following reason:
Other
Question by
John_Freeman · Nov 18, 2015 at 06:53 AM ·
unity 5scripting problemmovementnot workingvector2
My movement script is not moving my 2D object
Here is what I have so far.
using UnityEngine;
using System.Collections;
public class PlayerControl : MonoBehaviour
{
public float movementSpeed = 10f;
void Update () {
if(Input.GetKey(KeyCode.UpArrow))
{
GetComponent<Rigidbody2D>().AddForce(new Vector2(0, 1) * movementSpeed * Time.deltaTime);
}
}
}
I want my object to move up when I press the up key and it seems to do nothing when I press the key. I'm new to Unity and I think I might have just missed something.
Comment
Answer by say_forever · Nov 18, 2015 at 07:17 AM
I tried you script and you are right!
I think you just need make Mass of Rigidbody2D be less 0.01.
Answer by John_Freeman · Nov 18, 2015 at 09:21 PM
Yeah even after extensive messing around with the settings on my Rigidbody 2D on my Player Prefab I still get nothing.