美文网首页
BVW1:Unity生成类似炮弹的算法实现

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

作者: LunarShade | 来源:发表于2018-09-09 23:41 被阅读0次

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);

        }

}

}

相关文章

网友评论

      本文标题:BVW1:Unity生成类似炮弹的算法实现

      本文链接:https://www.haomeiwen.com/subject/qzkjgftx.html