Good evening, I would like a help in a script, with a 2D game TopDown, I wish the enemies could throw arrows, straight line, but fowards the player, however, I could not make the arrow sprite spin on its axis Without affecting the straight trajectory. Tips to incorporate?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Blast : MonoBehaviour {
public float speed;
public GameObject player;
private Rigidbody2D myRigidbody;
private Animator anim;
public Vector3 vDirection;
public float angle;
// Use this for initialization
void Start () {
myRigidbody = GetComponent<Rigidbody2D>();
anim = GetComponent<Animator>();
vDirection = player.transform.position - gameObject.transform.position;
vDirection = vDirection.normalized;
}
void Update () {
player = BlasterAttack.PlayerT;
myRigidbody.velocity = transform.TransformDirection (vDirection * speed);
}