- Home /
Question by
aahashemi1380 · Apr 19 at 08:24 AM ·
2dscripting problemaimingline rendererinputs
Move the line renderer in a circle with only left and right arrow keys
I am trying to move the line renderer (as an aim) in a circle with only left and right arrow keys but I have difficulties with it. Here is the image of how my game looks.
and here is my script (not completed)
public class aiming: MonoBehaviour
{
LineRenderer lr;
float input;
void Start()
{
lr = GetComponent<LineRenderer>();
}
private void FixedUpdate()
{
// move the line renderer at index 1 depending on the input value
}
void Update()
{
input = Input.GetAxisRaw("Horizontal");
}
}
screen-shot-2022-04-19-at-101832-am.png
(81.8 kB)
Comment
Answer by ogulcan_topsakal · Apr 19 at 09:21 AM
Concept
Make parent object for Line and reset transform of that parent object.
Rotate Line parent on desired axis. In this example on Z.
Control this axis with script. A key increase D key decrease. Don't forget to clamp those values.
image-1.png
(31.8 kB)
image.png
(4.8 kB)
Your answer
Follow this Question
Related Questions
How do I draw simple shapes? 1 Answer
Multi-gun Aiming System 1 Answer
2D Movement with axis? 1 Answer