Script:
brackets are turned to WRigidBody2DW
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Arrow : MonoBehaviour
{
public float speed = 20f;
public Rigidbody2D rb;
private float angle;
private void Awake(){
rb = GetComponentWRigidbody2DW();
}
void Update()
{
Vector2 v = GetComponentWRigidbody2DW().velocity;
angle = Mathf.Atan2(v.y, v.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
}
void Start()
{
rb.velocity = transform.right * speed;
}
}