# Trying to move player

I want to move my player (green cube) between the white blocks below it. I want when I push wasd to move the player 1 full block away with a little jump animation, like in done is some turn based games
Any ideas? thank you

i dont think you have reason for collitions and rigidbodys and the physics engine for something this simple ???

the easiest way i can think of to move the cube to the rounded positions is to make float values that represent where the cube should be and keep the cube moving towards it. obviosly these floats change with your “wasd”.

to create a smooth jump with a natural curve, you can add a positive float to the y position every frame. then slowly subtract from that float and it will naturally start subtracting from the y postion as it falls below zero and bring your cube back to ground level.

here is the idea to get you started.

``````public float x, y, z, j;
public float jumpspeed;
public float gravity;
public float speed;

void Start () {
speed = 1;
jumpspeed = .02f;
gravity = -.04f;
j = 0;
x = transform.position.x;
z = transform.position.z;
y = transform.position.y;
}

void Update () {
if(j==0){
if (Input.GetKeyDown("a")){x-=1;j=jumpspeed;}
if (Input.GetKeyDown("d")){x+=1;j=jumpspeed;}
if (Input.GetKeyDown("w")){z+=1;j=jumpspeed;}
if (Input.GetKeyDown("s")){z-=1;j=jumpspeed;}}

//this part makes the jump
if (transform.position.y > y||j==jumpspeed) {
j+=Time.deltaTime*gravity;}else{j=0;}
transform.position = new Vector3(transform.position.x,
transform.position.y+j,
transform.position.z);

//this part keeps character moving toward x and y
transform.position = Vector3.MoveTowards(transform.position,new Vector3(x,transform.position.y,z),Time.deltaTime*speed);
}
``````