…method or property. Hey all. I have been wondering about making a system where my ‘2D’ sprite character walks up, down, left, right and so on on a grid. I have made a little script and I get the same issue after trying many different methods.
This is the part of code the error apears on:
Transform.position += Vector3.right;
Transform.position += Vector3.left;
Transform.position += Vector3.down;
Transform.position += Vector3.up;
This is the entire code:
using UnityEngine;
using System.Collections;
public class ChracterControler : MonoBehaviour {
public float snapValue = 1;
public float depth = 0;
void Update(){
float x, y, z;
if (Input.GetKey ("w"))
Transform.position += Vector3.up;
if (Input.GetKey ("a"))
Transform.position += Vector3.left;
if (Input.GetKey ("d"))
Transform.position += Vector3.right;
if (Input.GetKey ("s"))
Transform.position += Vector3.down;
float snapInverse = 1 / snapValue;
x = Mathf.Round(transform.position.x * snapInverse) / snapInverse;
y = Mathf.Round(transform.position.y * snapInverse) / snapInverse;
z = depth;
}
}