As above, right now I am making a project in my school. The problem is that I cannot move my “sprite”. I inserted a picture of a character we set as a sprite, I also inserted a picture of a the ground. Both are set to sprites, they also have a box collider, my character also have rigdbody. Now to the script, I tried so many ways to get my sprite moving but it wont.
This is my lastest script I tried:
using UnityEngine;
using System.Collections;
public class Movement : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
Movement ();
}
void Movement()
{
if(Input.GetKey (KeyCode.D))
{
Transform.Translate(Vector2.right * 4f * Time.deltaTime);
}
if(Input.GetKey (KeyCode.A))
{
Transform.Translate(Vector2.right * 4f * Time.deltaTime);
}
}
}
Any suggestions?
Thanks.
PS.I had the script equppied. It gave me an error telling.
"
Movement.Movement()': member names cannot be the same as their enclosing type