Quantcast
Channel: Questions in topic: "javascript"
Viewing all articles
Browse latest Browse all 68

Why does WASD move my player quicker than with a joystick?

$
0
0
For some reason, if you use a keyboard to move my player it's faster than a joystick. Can anyone help me? Here's my code: #pragma strict var moveSpeed : float; var clampRadius : float; var dashSpeed : float; var walkSpeed : float; var horizontalDirection : int; var verticalDirection : int; var rb2D : Rigidbody2D; var movement : Vector2; function Update () { movement.x = Input.GetAxis("Horizontal"); movement.y = Input.GetAxis("Vertical"); } function FixedUpdate () { //move rb2D.MovePosition(rb2D.position + movement * moveSpeed * Time.fixedDeltaTime); movement = Vector3.ClampMagnitude(movement, clampRadius); //dash if(Input.GetKeyDown(KeyCode.Space) == true) { rb2D.MovePosition(rb2D.position + movement * dashSpeed * Time.fixedDeltaTime); } //walk if(Input.GetKey(KeyCode.LeftShift) == true && !Input.GetKeyDown(KeyCode.Space) == true) { rb2D.MovePosition(rb2D.position + movement * walkSpeed * Time.fixedDeltaTime); } }

Viewing all articles
Browse latest Browse all 68

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>