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);
}
}
}
网友评论