x


Player Movement

Hey folks,

so i have this simple and working code

float moveX = Input.GetAxisRaw("Horizontal");
float moveY = Input.GetAxisRaw("Vertical");
if (Mathf.Abs(moveX) > 0.1f || Mathf.Abs(moveY) > 0.1f){
        float moveDelta = flySpeed * Time.deltaTime;
        transform.Translate(moveX * moveDelta, moveY * moveDelta, 0, Space.World);
    }

if i press and hold A to move left and then press D to move right without releasing A the player stops moving, same goes the opposite way. my question is, how can i change that behaviour? the player should move the new way.

thanks

more ▼

asked Jan 26 '11 at 01:48 PM

Vaz gravatar image

Vaz
1 2 2 2

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Use Input.Getkey() instead GetAxis. Cause if A is -1 and D is 1, what is if you have +1-1?
0

more ▼

answered Jan 26 '11 at 01:56 PM

Borgo gravatar image

Borgo
998 9 13 25

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1362
x951

asked: Jan 26 '11 at 01:48 PM

Seen: 1139 times

Last Updated: Jan 26 '11 at 01:48 PM