#helping halfsqvl

1 messages · Page 1 of 1 (latest)

ivory grotto
#

@rose basalt so you should have a joystick prefab already

rose basalt
#

yes

#

i have a working movemwnt scripr

#

and i need aiming

ivory grotto
#

alright you basically slap another joystick prefab on your game, that should be your aiming stick

#

and you get your horizontal float from it, like you did for your movement script

rose basalt
#

yea

ivory grotto
#

then you use that float to change your character rotation

#

something like

#

horizontal = aimingJoystick.Horizontal;
transform.rotation = Quaternion.Euler(horizontal..)

rose basalt
#

in new script?

ivory grotto
#

up to you, you can keep it clean and make a separate script, call it aiming

#

PlayerAim or w/e u want

ivory grotto
#

well in theory yes, once you move the joystick left and right your character should rotate

rose basalt
#

but you need here vertical

#

to rotate

#

??

#

or z

#

i think

ivory grotto
#

just the y axis, because if you move the x and z axis your character will start rotating weirdly

#

im thinking about this from the same way you'd script a mouse character rotation

rose basalt
#

but i thing X will rotate under map

#

think*

ivory grotto
#

yea it will

#

i said just the y axis

rose basalt
#

y axis too

ivory grotto
#

why would the y axis do that as well?

#

the green axis is your y axis, thats what yo uwant to rotate through code

#

and rotationg it should only rotate horizontally, not vertically

rose basalt
#

umm

#

but in mine ita 2d so z is rotate

#

i think

ivory grotto
#

oh well sure in 2d space your axis might be different

rose basalt
#

you move it left and right with x and y

ivory grotto
#

alright where regardless of which axis you need to use, that should be your starting script

rose basalt
#

but

#

you nees to change horitzontal to z

#

but how

ivory grotto
#

when you do Quaternion.Euler you got 3 values

rose basalt
#

ik im stupid but help

ivory grotto
#

Quaternion.Euler(x, y, z)

#

you place your variable in the z, set x and y to 0

rose basalt
#

horizontal = aimingJoystick.Horizontal;
transform.rotation = Quaternion.Euler(0, 0, z)

#

this?

ivory grotto
#

your variable, man 💀

#

meaning horizontal

rose basalt
#

show me

ivory grotto
#

thats what you need to be passing through z

#

think about it like this man, your horizontal float is storing your joystick input values, when it goes -1 is left, 1 is right

#

so now you got those values stored in a variable

#

now you need to use that variable to affect your player rotation

#

with Quaternion.Euler you are setting your rotation to that input

rose basalt
#

sooo

#

what float

#

likw

#

how to write it

ivory grotto
#

thats some basic stuff man, you know what a float is right?

rose basalt
#

yes

#

float is variable

ivory grotto
#

alright, so you create your float up above

#

then in update you update that float

#

like you did for hte player movement

#

you have a horizontal float above

#

then in update

#

you have horizontal = Joystick.Horizontal;

rose basalt
#

aghhhhh

ivory grotto
rose basalt
#

ohhh i know what you mean

#

float z;
.........

z = joytick

#

no

#

this is stupid

ivory grotto
#

it doesnt matter what you call it

#

it can be float alabama; and alabama = Joystick.Horizontal;

#

then you do, in update

#

transform.rotation = Quaternion.Euler(0, 0, alabama);

#

did you manage to implement it ?

rose basalt
#

oh i know

#

but its just vertical

ivory grotto
#

yeah then put it in the middle