Quantcast
Channel: Questions in topic: "addforce"
Viewing all articles
Browse latest Browse all 1264

Bullets falling through the terrain

$
0
0
Hello, I am still fairly new to unity. I am trying to create a 3rd person FPS game, and I looked at some guides on the internet and on Youtube but couldn't find an answer to my issue. My issue right now is that I can get the spheres to fire from an empty game object that is attached to the main character, but as it fires the empty game object keeps drifting down further and further (although it says in the inspector that it isn't). The odd part, however, is that they still occasional fire from the empty object while still firing in the constant stream that is drifting downward. Here is the code I am using for the bullet firing script: using UnityEngine; using System.Collections; public class FireSphere : MonoBehaviour { // Use this for initialization public GameObject Bullet_Emitter; public GameObject Bullet; public float Bullet_Destroy_Time; void Start () { } // Update is called once per frame void Update () { if (Input.GetKeyDown("f") || Input.GetMouseButton(0)) { //The Bullet instiation happens here GameObject Temporary_Bullet_Handler; Temporary_Bullet_Handler = Instantiate(Bullet, Bullet_Emitter.transform.position, Bullet_Emitter.transform.rotation) as GameObject; Rigidbody Temporary_RigidBody; Temporary_RigidBody = Temporary_Bullet_Handler.GetComponent(); Temporary_RigidBody.constraints = RigidbodyConstraints.FreezePositionY; Temporary_RigidBody.velocity = transform.forward * 50; /// Temporary_RigidBody.AddForce(transform.forward * 1000); Destroy(Temporary_Bullet_Handler, Bullet_Destroy_Time); } } }

Viewing all articles
Browse latest Browse all 1264

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>