- Home /
How to get 360 directions from [joystick/mouse] instead of 8?
Hello, there,
I am working on a game, where player is used to move with [WASD / left joystick], and attack with [mouse(delta) / right joystick]. I have set both of them as Inputs, but i am meeting a problem. There's a game by supercell, called "Brawl stars" and if you have ever played that, you should know there is a sketch which shows where you are sbout to shoot. I am trying to make exact on but with a spotlight, so the light shows where you are about to shoot.
Here's a picture of my game look:
And here's another of Brawl stars look:
As I said, I have a problem and it is about aiming control. I can fully control the ragdoll, but the spotlight doesnt follow the mouse, I tried making the spotlight setting its rotation exact as joystick/mouse movement rotation, but i got it only to 8 directions (x+y+/x+y-/x-y-/x-y+/x+y0/x-y0/x0y-/x0y+), meaning i can shoot only in 8 directions, which isn't enough, as i want it to be able to shoot in any (360°) direction.
Any suggestions, how can I extract more directions out of joystick/mouse(delta) Input? Here's how I did it:
private void FixedUpdate()
{
if (aimInput.x != 0 || aimInput.y != 0)
{
aimRad = Mathf.Atan2(aimInput.x, aimInput.y);
aimDeg = Mathf.Rad2Deg * aimRad;
}
aim.transform.rotation = Quaternion.Euler(0, aimDeg, 0);
}
Answer by pradeeppurigoswami7 · May 13, 2021 at 06:02 AM
Your spotlight used in the Player object Attach so, your Spotlight work properly...
You probably don't get it, but I want my spotlight to be controlled by mouse or joystick Input, and yes it is attached, thats how it works... so far.
Your answer
![](https://koobas.hobune.stream/wayback/20220613033634im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Rotate player to aim on one axis (Z-axis) towards mouse position/joystick - 2.5D (3D) 0 Answers
Point an arrow at the mouse position, 2.5D 1 Answer
Implementing a simple on-screen joystick for mouse 0 Answers
How to incorporate a rotation towards mouse position in this script? I tried 0 Answers
Raycasting from object rotation? 1 Answer