#i did it and it just stays normal it
1 messages · Page 1 of 1 (latest)
Show code
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
that is the code in my script rn
||@uncut falconsorry for ping ||
You're still setting horizontal to the axis here:
horizontal = Input.GetAxisRaw("Horizontal");
You want to read the axis in the ifs instead of this variable
And not change horizontal anywhere else
Just read through it top to bottom. Horizontal is set to be whatever the joystick is, then you change it if the joystick is greater than 0 (moving right) or less than 0 (moving left), but since you already gave it a value, it'll remain at 0 if the joystick is at 0. You don't want it to be 0, since you want the movement to "stick", so you shouldn't change horizontal from whatever it used to be if the joystick isn't moving. Easiest way is to check the joystick directly in those ifs instead of storing it in a variable first
for some reason my code still does not work but this time it will not let me move
i am setting horizontal to 1 if it is > 0 right?
or am i like adding 1
You should be setting it
not adding
Show the code how it currently is
it is the exact same as it was in the pastebin without the getaxisraw
So did you just remove that line and not change the ifs?
correct
You still need to check the horizontal axis before changing horizontal.
You just don't want to change it before the ifs
how would i state horizontal
this is my code
if (horizontal > 0)
{
horizontal = 1;
}
else if (horizontal < 0)
{
horizontal = -1;
}
for the ifs
Instead of checking if the variable horizontal is above or below 0, check if the input's horizontal axis is