BVW1:Unity生成类似炮弹的算法实现

2018-09-09  本文已影响0人  LunarShade

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class InstantiateController : MonoBehaviour {

    public Rigidbody shell;

    public Transform transform;

    public float addForce = 10f;

    public float randomAngle;

// Use this for initialization

void Start () {

}

// Update is called once per frame

void Update () {

if(Input.GetKeyDown(KeyCode.A))

        {

            randomAngle = Random.Range(-0.2f, 0.2f);

            Rigidbody shellInstantiate = Instantiate(shell, transform.position, transform.rotation) as Rigidbody;

            shellInstantiate.velocity = addForce * new Vector3 (randomAngle, -0.1f, 1);

        }

}

}

上一篇 下一篇

猜你喜欢

热点阅读