Guest User

Untitled

a guest
Feb 19th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 KB | None | 0 0
  1. float axisH=0;//= Input.GetAxis("Horizontal");
  2.         float axisV=0;//=Input.GetAxis("Vertical");
  3.         bool upPressed=Input.GetKey("w") || Input.GetKey("up");
  4.         bool downPressed=Input.GetKey("s") || Input.GetKey("down");
  5.         bool leftPressed=Input.GetKey("a") || Input.GetKey("left");
  6.         bool rightPressed=Input.GetKey("d") || Input.GetKey("right");
  7.        
  8.         if(leftPressed) axisH=-1f;
  9.         if(rightPressed) axisH=1f;
  10.         if(upPressed) axisV=1f;
  11.         if(downPressed) axisV=-1f;
  12.        
  13.         if(leftPressed&&rightPressed) axisV=0f;
  14.         if(upPressed&&downPressed)axisH=0f;
  15.        
  16.  
  17.         //bewegen
  18.  
  19.         float amtToMoveX = axisH * playerSpeed * Time.deltaTime;
  20.  
  21.         //transform.Translate(Vector3.right * amtToMoveX);
  22.         transform.position=new Vector3(transform.position.x+amtToMoveX,transform.position.y,transform.position.z);
  23.  
  24.         float amtToMoveY = axisV * playerSpeed * Time.deltaTime;
  25.  
  26.         //transform.Translate(Vector3.up * amtToMoveY);
  27.         transform.position=new Vector3(transform.position.x,transform.position.y+amtToMoveY,transform.position.z);
Add Comment
Please, Sign In to add comment