Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float axisH=0;//= Input.GetAxis("Horizontal");
- float axisV=0;//=Input.GetAxis("Vertical");
- bool upPressed=Input.GetKey("w") || Input.GetKey("up");
- bool downPressed=Input.GetKey("s") || Input.GetKey("down");
- bool leftPressed=Input.GetKey("a") || Input.GetKey("left");
- bool rightPressed=Input.GetKey("d") || Input.GetKey("right");
- if(leftPressed) axisH=-1f;
- if(rightPressed) axisH=1f;
- if(upPressed) axisV=1f;
- if(downPressed) axisV=-1f;
- if(leftPressed&&rightPressed) axisV=0f;
- if(upPressed&&downPressed)axisH=0f;
- //bewegen
- float amtToMoveX = axisH * playerSpeed * Time.deltaTime;
- //transform.Translate(Vector3.right * amtToMoveX);
- transform.position=new Vector3(transform.position.x+amtToMoveX,transform.position.y,transform.position.z);
- float amtToMoveY = axisV * playerSpeed * Time.deltaTime;
- //transform.Translate(Vector3.up * amtToMoveY);
- transform.position=new Vector3(transform.position.x,transform.position.y+amtToMoveY,transform.position.z);
Add Comment
Please, Sign In to add comment