I am modifying a shooting game where instead of the bullet traveling straight up, I want it to act under gravity and move in a parabolic motion. Right now, I have the bullet moving in a straight line with a positive slope. Is there any way I can change my code for the bullet to make it behave this way? My game is in 2D and also uses the X-axis and Y-axis. Here is the bulletScipt:
var bulletSpeed : int;
var bulletAngle: float;
var explosion : Transform;
useGravity = true;
function FixedUpdate () {
amtToMove = bulletSpeed * Time.deltaTime;
transform.Translate(Vector3.right + Vector3.up * amtToMove);
if(transform.position.y >=6.7){
Destroy(gameObject);
}
if(transform.position.y <= -5){
Destroy(gameObject);
}
}
function OnTriggerEnter(otherObject: Collider){
if(otherObject.gameObject.tag == “enemy”){
playerScript.playerScore += 50;
otherObject.gameObject.transform.position.y = 7;
otherObject.gameObject.transform.position.x = Random.Range(-6,6);
var tempExplosion: Transform;
tempExplosion = Instantiate(explosion, transform.position, transform.rotation);
Destroy(gameObject);
}
}
function OnGUI()
{
GUI.Label(Rect(10,70,200,50),"Bullet Velocity: "+ bulletSpeed);
GUI.Label(Rect(10,90,200,50),"Bullet Angle: "+ bulletAngle);
}