记录一下,
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BulletTest : MonoBehaviour
{
private Vector2 target_pos;
private Rigidbody2D _rigidbody;
private float x_Speed=10;
private float mass = -9.8f;
private float y_speed;
private float moveTime;
private Vector3 MoveSpeed;
private Vector3 MasSpeed = Vector2.zero;
private bool ismove = false;
public void Init(Transform monster)
{
target_pos = monster.position;
float x = target_pos.x - transform.position.x;
float y = -transform.position.y + target_pos.y;
//计算箭只移动到目的地的时间
moveTime = x / x_Speed;
//计算y轴上的初始速度
y_speed = y / moveTime - 0.5f*mass * moveTime;
//初始速度向量
MoveSpeed = new Vector3(x_Speed, y_speed);
//旋转角度
float eul = Mathf.Atan(y_speed / x_Speed) * 180 / Mathf.PI;
this.