Problem with rotating my object

Hello everyone!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
public Animator animator;
public GameObject crossHair;
public GameObject ArrowPrefab;

// Update is called once per frame
void Update ()
{
    Vector3 movement = new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), 0.0f);

    animator.SetFloat("Horizontal", movement.x);
    animator.SetFloat("Vertical", movement.y);
    animator.SetFloat("Magnitude", movement.magnitude);

    AimAndShoot();

    transform.position = transform.position + movement * Time.deltaTime;
}

private void AimAndShoot()
{
    Vector3 aim = new Vector3(Input.GetAxis("AimHorizontal"), Input.GetAxis("AimVertical"), 0.0f);
    Vector2 shootingdirection = new Vector2(Input.GetAxis("AimHorizontal"), Input.GetAxis("AimVertical"));

    if (aim.magnitude > 0.0f)
    {
        aim.Normalize();
        aim *= 0.4f;
        crossHair.transform.localPosition = aim;
        crossHair.SetActive(true);

        shootingdirection.Normalize();
        if (Input.GetButtonDown("Cancel"))
        {
            GameObject Arrow = Instantiate(ArrowPrefab, transform.localPosition , Quaternion.identity);
            Arrow.GetComponent<Rigidbody2D>().velocity = shootingdirection * 3.0f;
            Arrow.transform.Rotate(0.0f, 0.0f, Mathf.Atan2(shootingdirection.x, shootingdirection.y) + Mathf.Rad2Deg);
            Destroy(Arrow, 1.0f);
        }
    }
    else
    {
        crossHair.SetActive(false);
    }
}

}

So what’s the problem with my code
I want to rotate my arrow where my aim is facing but it doesn’t work:(
I am just new to Unity…:slight_smile:
Here is the image:

Hello there. You’re actually trying to rotate that sprite 2D on the Z axis, supposedly in a 2D world you wouldn’t have a Z axis. Try rotating it on the X or Y axis depending on what you need.

This answer might do the trick for you: Rotate towards velocity (2D) - Questions & Answers - Unity Discussions