Question by
wintellwallen · Jun 26, 2021 at 07:36 AM ·
2d2d game2d rotation
I want to rotate my character using analog stick. I have set up rotating towards mouse cursor
void Update()
{
move.x = Input.GetAxisRaw("Horizontal");
move.y = Input.GetAxisRaw("Vertical");
dir = Input.mousePosition - Camera.main.WorldToScreenPoint(transform.position);
angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
if (Input.GetButton("Jump") && Time.time > nextDashTime){
Dash();
}
}
private void FixedUpdate() {
rb.rotation = angle;
rb.MovePosition(rb.position + move * speed * Time.fixedDeltaTime);
}
Here's the code. How can I change the script to rotate towards mouse and rotate with right analog stick ?
,
Comment