#helping halfsqvl
1 messages · Page 1 of 1 (latest)
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
yea
then you use that float to change your character rotation
something like
horizontal = aimingJoystick.Horizontal;
transform.rotation = Quaternion.Euler(horizontal..)
in new script?
up to you, you can keep it clean and make a separate script, call it aiming
PlayerAim or w/e u want
and thats it?
well in theory yes, once you move the joystick left and right your character should rotate
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
y axis too
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
oh well sure in 2d space your axis might be different
you move it left and right with x and y
yes
alright where regardless of which axis you need to use, that should be your starting script
when you do Quaternion.Euler you got 3 values
ik im stupid but help
horizontal = aimingJoystick.Horizontal;
transform.rotation = Quaternion.Euler(0, 0, z)
this?
show me
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
thats some basic stuff man, you know what a float is right?
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;
aghhhhh
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 ?
yeah then put it in the middle