Projectile Motion
카테고리 없음 2013. 8. 6. 17:37http://www.phy.hk/wiki/englishhtm/ThrowABall.htm
http://www.rabidgeek.net/physics-applets/projectile-motion/
http://blog.daum.net/kimjisune/15
http://blog.daum.net/sexyguy085101/8
using UnityEngine;
using System.Collections;
public class Controller : MonoBehaviour {
public Transform bullet; // 포물체
private float _tx;
private float _ty;
private float _v;
private float _g = 9.8f;
private bool _isShoot = false;
private float _tic = 0.5f;
private float init_speed = 20f;
private float init_angle = 78;
private float _t;
void Awake()
{
}
void Start () {
}
void Update () {
if (this._isShoot) {
if (bullet.position.y >= 0) {
this._tic -= Time.deltaTime;
this._v = this._g * Time.deltaTime;
this._tx = (this.init_speed * Mathf.Cos(this.init_angle * Mathf.Deg2Rad) * Time.deltaTime);
this._ty = this.init_speed * (Mathf.Sin(this.init_angle * Mathf.Deg2Rad) * this._tic) - ((this._v * this._tic) / 2);
bullet.Translate(this._tx, this._ty * Time.deltaTime, 0);
}
}
}
void OnGUI() {
if( GUI.Button(new Rect(0, 0, 100, 100), "Shoot")){
Debug.Log("shoot!");
this._isShoot = true;
}
}
}