Question by
Gatling-Hawk-youtube · May 12, 2016 at 03:25 PM ·
shootingdirectiongrenade
Projectile direction problem Please Help!
When i grab the emitter(which is child of fps camera) and place it into the prefab spot, the grenade pops out fine. it instantiate with the proper direction in which I'm facing, left or right. BUT NOT UP AND DOWn with the camera. . //code here using UnityEngine; using System.Collections;
public class Shoot : MonoBehaviour {
public GameObject Grenade_Emitter;
public GameObject Grenade;
public float Grenade_Forward_Force;
public float Grenade_up_Force;
// initialization
void Start ()
{
}
// Update per frame
void Update ()
{
if (Input.GetMouseButtonDown(0))
{
GameObject Temporary_Grenade_Handler;
Temporary_Grenade_Handler = Instantiate(Grenade,Grenade_Emitter.transform.position,Grenade_Emitter.transform.rotation) as GameObject;
Temporary_Grenade_Handler.transform.Rotate(Vector3.left * 90);
Rigidbody Temporary_RigidBody;
Temporary_RigidBody = Temporary_Grenade_Handler.GetComponent<Rigidbody>();
Temporary_RigidBody.AddForce(transform.forward * Grenade_Forward_Force);
Temporary_RigidBody.AddForce(transform.up * Grenade_up_Force);
Destroy(Temporary_Grenade_Handler, 3.5f);
}
}
}
Comment