using UnityEngine; using System.Collections; public class Shoot : MonoBehaviour {
public float Power = 60.0f; public GameObject ballPrefab; // Update is called once per frame void Update () { if(Input.GetButtonDown("Fire1")) { GameObject newBall = (GameObject)Instantiate(ballPrefab,transform.position , Quaternion.identity); //with gravity and rigidbody
newBall.rigidbody.velocity = transform.rotation * Vector3.right * Power; } } }
|
'유니티3D > 예제' 카테고리의 다른 글
PopUpButton.cs (0) | 2013.09.11 |
---|---|
2DGameScripts (0) | 2013.09.10 |
UpDownRotate (0) | 2013.09.03 |
StreetLight.cs (0) | 2013.08.26 |
gamemanagel.cs (0) | 2013.08.26 |