#i did it and it just stays normal it

1 messages · Page 1 of 1 (latest)

gaunt marlin
#

anyway @uncut falcon i am using unity 2019

uncut falcon
#

Show code

gaunt marlin
#

that is the code in my script rn

#

||@uncut falconsorry for ping ||

uncut falcon
#

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

gaunt marlin
#

ohh ok

#

sorry im used to djs

#

idk much on c#

uncut falcon
#

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

gaunt marlin
#

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

uncut falcon
#

not adding

#

Show the code how it currently is

gaunt marlin
#

it is the exact same as it was in the pastebin without the getaxisraw

uncut falcon
gaunt marlin
#

correct

uncut falcon
#

You still need to check the horizontal axis before changing horizontal.

#

You just don't want to change it before the ifs

gaunt marlin
#

how would i state horizontal

#

this is my code

#
if (horizontal > 0)
        {
            horizontal = 1;
        }
        else if (horizontal < 0)
        {
            horizontal = -1;
        }
#

for the ifs

uncut falcon